Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 2.12 KB

File metadata and controls

70 lines (51 loc) · 2.12 KB

Manipulation of Singularity images

Once Bob understood that Singularity containers can be built, the next natural question that arises is how can they be manipulated.

The following collection of examples highlights the key functionality:

Building Singularity containers on host system

As the user does not necessarily have all the privileges, the question whether a container can still be built arises; the following tag addresses this issue:

singularity build --fakeroot

Binding directories

What if Bob wishes to present a directory to the singularity environment directly?

singularity -B /somefolder

The -B tag offers this functionality.

What about environment variables?

What if the initially set variables (%environment) are not sufficient?

singularity exec --env

More tips and tricks regarding the ENV variables are nicely summarised here.

Inspecting the definition files

Forgot what the image is exactly?

singularity inspect -d singularitySimage.sif

What about MPI-related parallelization?

If you are using the same machine for all processes, MPI works fine within the container. For multi-machine parallelism, however, each MPI rank must be a separate container:

mpirun singularity exec image.sif massivelyParallelTree.py

What about editing an existing image?

What if Bob forgot to install a particular library, and would like to make just this one little fix? Consider the following image:

sudo singularity build --sandbox minitest.sif docker://ubuntu

Note the --sandbox option? This enables editability. Once having such image, open the shell with:

singularity shell --writable minitest.sif

and perform any operations needed. The ENV variables are accessible in:

#!/bin/sh
#custom env code

Other useful options

  • nv: Leverage GPUs
  • bind: Bind mount directories to the containers
  • contain: isolate the container runtime from the host
  • cleanenv: Clean the environment
  • pwd: Initial working directory within the container