Docker

From SciNet Users Documentation
Revision as of 18:03, 17 July 2021 by Nolta (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Docker is not available on SciNet's clusters. However, you can use singularity to run commands in docker images.

Pulling a docker image

$ singularity pull docker://alpine:latest

This pulls the alpine:latest image from Docker Hub and converts it to singularity's image format, saving it as a file named alpine_latest.sif.

As this requires an internet connection to work, it can only be done on the login nodes, and not in job scripts.

You can also pull from other docker registries, e.g.:

 $ singularity pull docker://quay.io/biocontainers/samtools:1.13--h8c37831_0

This creates an image file named samtools_1.13--h8c37831_0.sif.

Running a command inside an image

$ singularity exec alpine_latest.sif cat /etc/alpine-release
3.14.0
$ singularity exec samtools_1.13--h8c37831_0.sif samtools --version
samtools 1.13
Using htslib 1.13
...

Binding directories

Like docker, singularity containers have their own filesystems, and can't see files on the host system by default. So for example, your scratch space is not visible inside the container:

$ singularity exec alpine_latest.sif ls $SCRATCH
ls: /scratch/g/group/user: No such file or directory

To access directories on the host system, you need to bind them into the container:

$ singularity exec --bind="$SCRATCH" alpine_latest.sif ls $SCRATCH

You can change the bound directory name inside the container:

 $ singularity exec --bind="$SCRATCH:/data" alpine_latest.sif ls /data

To bind multiple directories, use a comma separated list:

 $ singularity exec --bind="$SCRATCH:/data,$PROJECT" alpine_latest.sif ls /data $PROJECT

Unlike docker, singularity containers are read-only. Files may only be written to host directories.

Also unlike docker, singularity will automatically bind your home directory. To disable this, use the --no-home option.