Docker containers can be used with SGE with the help of Singularity.
Singularity will run your container as your own user and will not require sudo privileges (like Docker does) which could lead to potential security issues since SGE is a multi-user environment where users should only be allowed access to their own data.
You can use the following to run a Docker container from Singularity (using the “hello-world” example:
singularity run docker://hello-world
This will not really run the Docker container from Singularity but will download the “hello-world” Docker image and will create a Singularity image from it. Once the Singularity image is created it will be run.
Creating a Singularity image from Docker before using it on SGE.
It is better to create the Singularity image from the Docker image before using it on SGE. To create the Singularity image from the Docker image you would use the following (again using the “hello-world” example):
singularity pull hello-world.simg docker://hello-world
The preceding command will create the Singularity hello-world.simg image in the current directory.
There is something to take care of using this approach. Singularity uses a cache and a temporary directory when processing images. By default, the cache directory will be located at your home directory at ~/.singularity/cache and the temporary directory will be defined as /tmp. That means that using the default parameters there could be not enough space to process the image.
You can define the temporary and cache directories using a storage location with enough space for the image to be processed. For example:
export SINGULARITY_CACHEDIR=/export/data/singularity_files/cache export SINGULARITY_TMPDIR=/export/data/singularity_files/tmp
In the context of SGE, make sure that /export/data is shared via NFS.
Parameter correspondence between a Singularity image and a Docker image.
Sometimes your Docker image will need some parameters to be passed. We’ll use the Docker image from leonyichencai/synb0-disco as an example.
The Docker version will use the following format:
sudo docker run --rm \ -v $(pwd)/INPUTS/:/INPUTS/ \ -v $(pwd)/OUTPUTS:/OUTPUTS/ \ -v <path to license.txt>:/extra/freesurfer/license.txt \ --user $(id -u):$(id -g) \ leonyichencai/synb0-disco:v3.0 <flags>
The corresponding Singularity call would be:
singularity run -e \ -B INPUTS/:/INPUTS \ -B OUTPUTS/:/OUTPUTS \ -B <path to license.txt>:/extra/freesurfer/license.txt \ <path to synb0.simg> <flags>