Skip to content

Docker introduction

Nelly Sélem edited this page Jan 26, 2018 · 4 revisions

Docker is the company driving the container movement. Its containers are compatible with cloud services like Amazon web servers that allows to rent great computational power instead of buying big servers.

A docker image is a way to wrap on a container a piece of software along with all its dependencies, assuring that the software will stay functional resisting the evolving versions of dependencies and the passing time. Along this tutorial several docker images were requested, this appendix explains in detail the general structure of the commands frequently used.

Docker image downlaoding

docker pull nselem/newevomining:latest

docker word always start a docker command, then comes the verb. On this case the verb is pull, indicating that the docker engine should pull the image nselem/newevomining into your computer. This image correspond is stored at the dockerhub on the nselem account.

Docker image running example:

docker run -i -t -v $(pwd):<Docker directory> -p 80:80 <image name> /bin/bash

docker run means that the docker engine will run an image, the one indicated on the image name. On this tutorial images used are nselem/newevomining and nselem/myrast.

The modifiers -i -t -v means respectively interactive mode, with a terminal and with a volume system. A volume is a way to share files between the computer and the docker image. The path of a local directory and a fixed path of the docker image separated by a colon are specified after the volume modifier -v. Whatever files exist in the local directory will be known by the docker image and every file produced inside the fixed docker path will be stored in the local directory and will persist when closing the docker image. The path to the local directory used in this tutorial is $(pwd), an abbreviation of print working directory. Examples of fixed docker directory paths are /home and /usr/src/CORE.

The /bin/bash at the end of the instructions means that the image should start with an interactive bash session, where other pieces of software can be run like perl or python scripts.

Finally, the -p 80:80 instruction in EvoMining stand for the interaction with a web browser on the port 80, sometimes this port is not available and another one should be selected.

Docker images

docker images displays a list of the available docker images on a computer.
docker rmi <IMAGE ID> removes selected images

Docker containers

Every time that you run an image a docker container is generated.
docker ps displays a list of all containers currently running at your computer.
docker rm <CONTAINER ID> removes selected containers
docker rm $(docker ps -a -q) removes old and unused containers.