Skip to main content

Docker/Singularity Containers

Some complex applications are sometimes packaged by their developers as Docker images to be run in containers.

Containers can be used on MCMeSU with the Singularity tool. which is a container solution specialized for scientific workloads.
Singularity is compatible with Docker registries and images.

Example of Singularity image pulling​

Below, we provide an example for pulling the GATK application from a Docker registry :

[user@mc-login1 ~]$ srun -c 4 -n 1 -N 1 --time=2:0:0 --pty /bin/bash

[user@mc-n0xx ~]$ module load singularity/4.2.2
[user@mc-n0xx ~]$ singularity pull docker://broadinstitute/gatk
[user@mc-n0xx ~]$ exit

Note that the image pulling is done within an interactive job that we initiate with the initial srun command.
You may ignore the warning messages that could occur during the pulling process.

Once the pulling process is done, the result should be a .sif file which is the Singularity image of the application that you can use from now on.
In our example, the resulting image file is named gatk_latest.sif and it is placed in our HOME which is our current working directory.

Example of running a command from a Singularity image​

Once the Singularity image has been built, you may use it within a job.

To do so, you simply have to add the following lines to your job script :

module load singularity/4.2.2

singularity run $HOME/gatk_latest.sif gatk

The singularity command can be run from any directory, for example from the SCRATCH directory where your data would probably be located.

In this example, we launch the gatk executable provided by the gatk_latest_sif image.
Any parameter that we would like to pass to the gatk executable shall come directly after it.