Ben Evans
October 22, 2019
Container Image: A self-contained, read-only file(s) used to run application(s)
Container: A running instance of an image
Linux Namespaces for hiding various aspects of host system from container.
Linux cgroups to limit RAM, CPU cores, etc.
When user is trusted: SELinx, AppArmor
When user is untrusted: run container as user
| Pro | Con |
|---|---|
| Light-weight | Linux-only* |
| Fast Startup | Another layer of abstraction |
| Shareable | Additional development complexity |
| Reproducible | Licensed software can be tricky |
GPU-enabled IPython w/TensorFlow on a GPU node:
Saved container for viral-ngs pipeline:


build a container imagerun (default behavior)CMD or %runscriptexec a commandPATH inside containershell session-s/--shellinspect an image-r to show runscripttype://[registry]/[namespace]/<repo_name>:[repo_tag]
Set before running to add to container:
To change where image files are cached:
# default is ~/.singularity
export SINGULARITY_CACHEDIR=~/scratch60/.singularity
# or
export SINGULARITY_CACHEDIR=/tmp/${USER}/.singularityAdd host directory to the container with -B/--bind:
/dataTo specify DockerHub credentials:
Quick way to determine which files are from image:
Bind GPU drivers properly when CUDA installed inside container:
mpirun inside container needs more setupI want to run RStudio and Tidyverse.
see: rocker-project.org
Job file
Reverse ssh tunnel:
Then connect to http://localhost:8787
Not ideal…
/etc/rstudio/rserver.confWhen you have to configure your own
/root$TMP or $HOMECMD for default runtime behaviorldconfig at the end of your DockerfileDockerfileA half-fix for my RStudio issue
FROM ubuntu:bionic
FROM ubuntu@sha256:6d0e0c26489e33f5a6f0020edface2727db9489744ecc9b4f50c7fa671f23c49Specify a default action.
build locallyimage lsREPOSITORY TAG IMAGE ID CREATED SIZE
rocker/rstudio latest 879f3fd2bee9 39 hours ago 1.12GB
ubuntu bionic 93fd78260bd1 13 days ago 86.2MB
image rmrun locally--rm to clean up container after it exits--volume to bind directories to container-e to set environment variables
-e USERID=$UID can avoid permission woespush to cloudprune uneeded thingsClean up every now and again.
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache
Are you sure you want to continue? [y/N]
Install Docker on MacOS, Windows, and Linux
Ubuntu and CentOS Docker Hub pages