Northwestern IT Research Computing Services
m-rich@northwestern.edu
(Or just look me up in the NU Directory)
Process isolation (for security)
Namespaces (better abstraction)
Process isolation AND Namespacing
And dependency packaging!
Docker was announced in 2013.
Docker offered relatively easy to use tools and better filesystem isolation.
Image repositories: Docker Hub, Biocontainers, private
Runtimes: single host, multi-host cluster, managed clusters
Standardization: image format and runtime environment
Docker runs as root!
This is a no-go for shared computing resources like Quest
Singularity is an alternative container technology designed for traditional HPC environments.
https://sylabs.io/singularity/
The running container will have exactly the environment defined in the image.
"Bind mounts" make the host's filesystem accessible inside the container.
Singularity containers can be run like any other command in a batch job.
Singularity supports GPU hardware via the --nv
flag.
MPI works seamlessly within a Singularity container (provided OpenMPI is installed).
$ module load singularity
Singularity can pull images from the Docker Hub:
$ singularity pull ubuntu.sif docker://ubuntu
This will create a singularity image file called ubuntu.sif
.
Singularity can pull images from the Singularity Hub:
$ singularity pull shub://nuitrcs/biobakery
https://www.singularity-hub.org/
Note: The Singularity Hub is an unsupported, community project.
Singularity can pull images from the Singularity Library:
$ singularity pull library://library/default/ubuntu:18.04
https://cloud.sylabs.io/library/
Note: The Singularity Library is supported by Sylabs.
You can build your own Singularity images with "recipe files".
Bootstrap: docker
From: continuumio/miniconda3
%environment
export LC_ALL=C
%post
/opt/conda/bin/conda install pandas matplotlib
%runscript
python
Images cannot be built on Quest.
https://cloud.sylabs.io/builder
Sylabs provides free image hosting and building.
Paste in a def file or use singularity build --remote!
Run an interactive shell in a container with the shell
subcommand:
$ singularity shell ubuntu.sif
Singularity: Invoking an interactive shell within container...
Singularity ubuntu.sif:~>
Run the image's default command with run
:
$ singularity run shub://nuitrcs/hello-world
Hello world!
Specify the exact command to run with exec
:
$ singularity exec docker://ubuntu cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
Singularity allows you to map directories on the host system (Quest) to directories in the container.
This lets software in a container access files on the host.
$HOME
and $TMP
are mapped by default.
Use the -B
flag to map additional directories:
$ singularity shell -B /projects/pXXXXX:/project ubuntu.sif
Singularity: Invoking an interactive shell within container...
Singularity ubuntu.sif:~> ls /project
You have the same permissions inside the container as on the host.
SSH to the workshop server.
$ ssh tempuserXX@quest.northwestern.edu
Pull an image from the Docker Hub.
$ singularity pull docker://python
How big is the file in mb?
What happens if you execute the file?
Pull an ubuntu image and run a shell inside it.
$ singularity shell docker://ubuntu
Try listing the files in your $HOME
directory.
Try creating a file in your $HOME
directory.
Try creating a file in /etc
.
Where is the image file?
Build an image from a recipe file.
First visit https://cloud.sylabs.io/builder and generate and save auth token.
$ git clone https://github.com/nuitrcs/singularity-workshop.git
$ cd singularity-workshop/pandas-example
$ singularity build --remote pandas_example.sif pandas_example.def
$ singularity run pandas_example.sif Evanston_Arrests.csv
Pull a bioinformatics image and run it.
$ singularity pull blast.sif docker://biocontainers/blast:2.2.31
$ cp /projects/w10001/data/* . # copy zebrafish.1.protein.faa and P04156.fasta to cwd
$ singularity exec blast.sif makeblastdb \
-in zebrafish.1.protein.faa -dbtype prot
$ singularity exec blast.sif blastp \
-query P04156.fasta -db zebrafish.1.protein.faa \
-out results.txt
Submit a batch job that uses Singularity.
$ sbatch batch_example.sh
Then watch your current working directory for the job output!
m-rich@northwestern.edu