Download pre-built images
# Synopsis
singularity pull [pull options...] [output file] <container>
# From Sylabs cloud library
singluarity pull library://<user>/<collection>/<container[:tag]>
singularity pull library://library/default/ubuntu:16.04
# From Docker
singluarity pull docker://<user>/<image:tag>
singularity pull docker://ubuntu:16.04
# From Shub
singluarity pull shub://<user>/<image:tag>
singularity pull shub://singularityhub/ubuntu:latest
# Rename image
singluarity pull <output file> <container>
singularity pull explorer.img shub://qlan3/singularity-deffile:explorer
Build a container
# Build from URI
sudo singularity build <container> <URL>
sudo singularity build lolcow.simg library://sylabs-jms/testing/lolcow
# Build From a Singularity definition file
sudo singularity build <container> <deffile>
sudo singularity build lolcow.sif lolcow.def
# Build from a existing container on your local machine, convert images from one format to another
sudo singluarity build <new container> <old container>
sudo singularity build production.sif development/
# Creating writable --sandbox (container in a directory) directories
sudo singularity build --sandbox <sandbox> <old container>
sudo singularity build --sandbox lolcow/ library://sylabs-jms/testing/lolcow
Shell in a container
# Synopsis
singularity shell [shell options...] <container>
# Make the file system accessible as read/write
singularity shell --writable <container>
singularity shell explorer.img
Run a command within a container
# Synopsis
singularity exec [exec options...] <container> <command>
# Example
singularity exec /tmp/debian.sif cat /etc/debian_version
singularity exec /tmp/debian.sif python ./hello_world.py
cat hello_world.py | singularity exec /tmp/debian.sif python
sudo singularity exec --writable /tmp/debian.sif apt-get update
singularity exec instance://my_instance ps -ef
singularity exec library://centos cat /etc/os-release
Bind Paths and Mounts
# Synopsis
singularity run/exec/shell --bind src[:dest[:opts]] <container> [command]
# Example
singularity exec --bind /data:/mnt my_container.sif ls /mnt
singularity shell --bind /home/vagrant/Explorer explorer-env.img
Build images from scratch
# Create a sandbox image from base ubuntu image
sudo singularity build --sandbox <container> <file/URL/container>
sudo singularity build --sandbox ubuntu/ library://ubuntu
# Shell into the sandbox image
sudo singularity shell --writable <container>
# Install software and dependencies, keep track of the relevant commands
...
# Example
singularity pull explorer-env.img shub://qlan3/singularity-deffile:explorer
singularity shell -bind /home/vagrant/Explorer explorer-env.img
apt-get install git