Docker (hub.docker.com)

Getting started

Installing docker

Dependencies

sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Repo and install

#correct release candidate
# for Linux mint
var="bionic"
# for other
var=$(lsb_release -cs)

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $var stable"
# this stuff is stored under /etc/apt/sources.list.d
# you can edit or remove this file if there are some errors

sudo apt-get update

sudo apt-get install docker-ce
sudo usermod -a -G docker $USER
sudo reboot

Important commands

docker run --rm <imagename> <command> # runs image as a container and removes it afterwards  
docker pull <repositoryname/dockername> # basically git clone of a docker image
docker build -t <image_name> . # build a image from Docker file in .

docker images # shows all images
docker rmi <name> # removes a image

docker ps -a # shows all current containers (active and exited)
docker rm <name> # removes docker container (IMPORTANT if you want to clean up)

Creating docker images

ssh into docker containers

# get into the docker bash
docker run --name docker_running -d replikation/debian_basic /bin/bash
# this can be done to just activate a container:
docker run --name docker_running -d replikation/debian_basic sleep 8h
# afterwards it will exits and detach the container
# check all docker containers with
docker ps -a

More information here:

Run dockers examples

docker run --rm -it -v /path/to/example_data:/example_data andrewjpage/tiptoft tiptoft /example_data/ERS654932_plasmids.fastq.gz
docker run --rm -it -v /home/christian/Desktop/Docker_experimental_area:/Docker_experimental_area porechop porechop -i /Docker_experimental_area/all2.fastq -b /Docker_experimental_area/demultiplexed

Docker pipelines

docker run --rm -i replikation/nanopolish echo $((3+4888)) | \
docker run --rm -i replikation/nanopolish tr -d 1
 ```

## Docker Wildcards
* WILDCARDS in docker via run are only interpreted via shell
* so run a command like this with `sh -c`:

docker run --rm -i replikation/nanopolish sh -c 'ls /folder/*.fasta' ```

Clean up for dockers

update all docker images

docker images |grep -v REPOSITORY|awk '{print $1}'|xargs -L1 docker pull

stop all containers

docker stop $(docker ps -a -q)

remove all container

docker rm $(docker ps -a -q)

remove all untagged images

docker rmi $(docker images -f "dangling=true" -q)