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:
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 --fakerootWhat if Bob wishes to present a directory to the singularity environment directly?
singularity -B /somefolderThe -B tag offers this functionality.
What if the initially set variables (%environment) are not sufficient?
singularity exec --envMore tips and tricks regarding the ENV variables are nicely summarised here.
Forgot what the image is exactly?
singularity inspect -d singularitySimage.sifIf 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.pyWhat 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.sifand perform any operations needed. The ENV variables are accessible in:
#!/bin/sh
#custom env codenv: Leverage GPUsbind: Bind mount directories to the containerscontain: isolate the container runtime from the hostcleanenv: Clean the environmentpwd: Initial working directory within the container