aliases | author | created | modified | tags | title | |
---|---|---|---|---|---|---|
|
Maneesh Sutar |
2023-06-06 |
2024-10-05 |
Singularity Container Engine |
Docker images are stored in layers, so pull
must also combine those layers into a usable SingularityCE file (.SIF file).
To pull image from dockerhub:
singularity pull docker://<path>
To pull from container library (Sylabs)
singularity pull library://<path>
pull command creates a new .sif
file in the current directory.
To create images from other images or from scratch using a definition file
Also to convert an image between the container formats
e.g. Following commands downloads pre-build images from external sources and converts them to .sif
format
singularity build <IMAGE_PATH> docker://<path>
Equivalent to Dockerfiles. Standard extension is .def
.
A SingularityCE Definition file is divided into two parts:
-
Header: describes the core operating system to build within the container. Similar to
FROM
in Dockerfile. -
Sections: Similar to layers in Dockerfile. Each section in SIF file is defined by a
%
character followed by the name of the particular section.
The shell command allows you to spawn a new shell within your container and interact with it as though it were a virtual machine.Once inside of a SingularityCE container, you are the same user as you are on the host system
Equivalen to singularity exec <image file path> sh
The exec command allows you to execute a custom command within a container by specifying the image file.
To exec, a command to run MUST be passed.
The run command is same as docker, which will run the container using given image. This is equivalent to ./sif-file-path
. This calls %runscript
block from the defination file.
Use run --containall
to run a SingularityCE image in an isolated manner:
The instance start command allows you to create a new named instance from an existing container image that will begin running in the background. Name must be passed as argument after image file path. This calls %startscript
block from the defination file
To see list of running containers, singularity instance list
To stop container, singularity instance stop <name of container>
By default, Singularity mounts /home directory to the container.
To disable, run with --no-home
To clear env variables, run with --cleanenv
Just like Docker, --bind
and --mount
commands can be used to mount directories.
By default, SingularityCE bind mounts /home/$USER
, /tmp
, and $PWD
into your container at runtime.