Recipes and instructions:
aka Lightweight virtualisation
As a software:
Examples:
$ docker pull debian
$ docker pull debian:stretch
$ docker pull centos:7
$ docker pull rocker/r-ver:3.5.1
$ docker pull continuumio/miniconda:4.5.4
download image
docker commit
docker import & docker export
$ docker run debian /bin/echo 'Hello world!'
$ docker run debian:jessie /bin/echo 'Hello world!'
$ docker run debian:jessie cat /etc/issue
$ docker run debian:stretch cat /etc/issue
$ docker run -d debian:stretch tail -f /dev/null
$ docker run -d --name mycontainer debian:stretch tail -f /dev/null
$ docker ps
Run daemon
List runninng containers
Log and info of container
$ docker log mycontainer
$ docker inspect mycontainer
Actions on containers
$ docker stop mycontainer
$ docker start mycontainer
$ docker restart mycontainer
$ docker exec mycontainer /bin/echo 'Bye, moon!'
$ docker run -ti --name mycontainer2 debian:stretch /bin/bash
Execute on a running container
Run a container interactively (from the beginning). Stops when exiting
$ docker exec -ti mycontainer /bin/bash
Execute on a running container interactively
$ docker rm mycontainer
$ docker rmi myimage
$ docker ps -a
remove container, remove image
list all containers (even stopped ones)
save image as tar
$ docker save myimg > myimg.tar
save container as tar
$ docker export mycontainer > mycontainer.tar
import tar as image
$ docker import mycontainer.tar mycontainer:latest
Recipe file:
Dockerfile
docker run -d -v /db/test:/blastdb -p 8089:8081 --name myblast blastwww
Biocontainers: repository of bioinformatics containers
$ docker pull biocorecrg/debian-perlbrew:stretch
$ docker push myusername/mysexyimage
download image
upload image
docker-compose.yml
containers for HPC
Summarising
As of 2.4.x version
$ singularity build debian.sif docker://debian:stretch
$ sudo singularity build --sandbox debiandir docker://debian:stretch
Build read-only image from Docker
Build writable directory from Docker
$ singularity exec debian.sif /bin/echo 'Hello world'
$ singularity exec debian.sif env
$ singularity exec -e debian.sif /bin/echo 'Hello world';
$ singularity exec -e debian.sif env
Execute a command
Execute a command (with clean environment)
Execute a shell
$ singularity shell debian.sif
$ singularity run debian.sif
Execute defined runscript (parameters can be used)
sudo singularity build privateimg.sif docker-daemon://privateimg:latest
sudo singularity build privateimg.sif docker-archive://privateimg.tar
BootStrap: debootstrap
OSVersion: stretch
MirrorURL: http://ftp.fr.debian.org/debian/
Include: curl
%environment
BLAST_PROGRAM=blastp
BLASTDB=/blastdb
export BLAST_PROGRAM BLASTDB
%post
BLAST_VERSION=2.7.1
cd /usr/local; curl --fail --silent --show-error --location --remote-name ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/${BLAST_VERSION}/ncbi-blast-${BLAST_VERSION}+-x64-linux.tar.gz
cd /usr/local; tar zxf ncbi-blast-${BLAST_VERSION}+-x64-linux.tar.gz; rm ncbi-blast-${BLAST_VERSION}+-x64-linux.tar.gz
cd /usr/local/bin; ln -s /usr/local/ncbi-blast-${BLAST_VERSION}+/bin/* .
%labels
Maintainer Biocorecrg
Version 0.1.0
%runscript
echo "Blast application!"
exec $BLAST_PROGRAM "$@"
BootStrap: docker
From: continuumio/miniconda:4.5.4
%environment
PATH=/opt/conda/envs/blast-conda/bin:$PATH
export PATH
%post
PATH=/opt/conda/bin:$PATH
export PATH
conda env create -f /environment.yml && conda clean -a
%files
environment.yml
%labels
Maintainer Biocorecrg
Version 0.1.0
singularity run -B /db/test:/blastdb blastwww.sif
sudo singularity build blastmysql.sifSingularity
singularity run -B /db/test:/blastdb -B $(pwd)/config.json:/config/mysql.json blastmysql.sif
sudo singularity build mysql.sif Singularity.mysql
singularity exec -B /tmp/db:/var/lib/mysql mysql.sif mysql_install_db
singularity instance.start -B /tmp/db:/var/lib/mysql -B /tmp/socket:/run/mysqld mysql.sif mysql
singularity instance.list
singularity exec instance://mysql mysql -uroot -h127.0.0.1 -e "CREATE DATABASE blast; GRANT ALL PRIVILEGES on blast.* TO 'blast'@'%' identified by 'blast123' ;"
singularity instance.start -B /db/test:/blastdb -B $(pwd)/config.local.json:/config/mysql.json blastmysql.sif blast
singularity instance.list
singularity instance stop.blast
singularity instance.stop mysql