From Wikiversity
< DevOps(Redirected from Docker)
Jump to navigation Jump to search

Docker is a software available since 2013 that among other features performs operating-system-level virtualization also known as containerization


Docker offer the following features:

Installing Docker[edit]

You can read official Docker documentation about installing Docker on your system:

On macOS you can follow official documentation which requires to create and account to download installer. You can also try: brew cask install docker or try to follow instructions:

brew install docker docker-compose docker-machine(to install docker and docker-compose)
brew cask install virtualbox
docker-machine create --driver virtualbox default
docker-machine ls
docker-machine env default
eval $(docker-machine env default)
docker run hello-world (will pull hello-world image and run it on docker)

On Ubuntu: snap install docker


Following binaries will be installed: docker-init, docker-proxy, docker and dockerd

Verifying Docker installation[edit]

Once installed the Docker daemon, called "dockerd" should be running. You can also run docker run hello-world to verify docker correct installation.

Configuration files[edit]

  • Ubuntu: /etc/docker/daemon.json

Docker Releases (Docker Engine release notes)[edit]

Use: docker version[1] to check your version. You can download Docker CE source code from GitHub[2].

Docker Command Line[edit]

You can read official docker command line documentation in Before being able to run docker commands you will have to install Docker on your machine.

Some typical task using containers:

Docker verification commands[edit]

  • Verify correct installation: docker run hello-world

You will see some message similar to this one:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:

Docker image and container creation[edit]

  • Create a new docker image base on alpine linux distribution and login into the new container: docker run -it alpine sh
  • Create a new docker image: docker build
    • Create a new docker image by creating a new text file with instructions, usually called Dockerfile[3]: docker build -f /path/to/a/Dockerfile .
  • Create a container: docker create
  • Generate a mediawiki:1.27 image: docker build --tag mediawiki:1.27 . (you can use -t or --tag)
  • Execute or run a container based on mediawiki:1.27 image: docker run --name wikiFGA -p -d mediawiki:1.27

Docker Container Operation[edit]

  • Start an existing container: docker start CONTAINER_ID OR CONTAINER_NAME. See also docker run and differences[4].
  • Stop an running container: docker stop container_id
  • Show only running containers:
  • Login/Connect into a running container:
    • docker exec[9] -it <my_container_name> bash
    • docker exec -it <my_container_name> sh
  • Start stopped containers: docker start $(docker ps -a -q -f status=exited)
  • Restart all containers: docker restart $(docker ps -aq) previously docker restart $(docker ps -q)-a all -q quiet[10]

Start configuration behavior and restart policy[11][edit]

To configure the start configuration behavior or the restart policy for a container (both of them), use the --restart flag when using the docker run command. The value of the --restart flag can be any of the following:

  • Do not automatically restart the container. (the default): no
  • Restart the container if it exits due to an error, which manifests as a non-zero exit code: on-failure
  • Restart the container unless it is explicitly stopped or Docker itself is stopped or restarted: unless-stopped
  • Always restart the container if it stops: always

The following example starts a Redis container and configures it to always restart unless it is explicitly stopped or Docker is restarted:

$ docker run -dit --restart unless-stopped redis With docker inspect CONTAINER[12] you can verify RestartPolicy configuration.

To update restart policy execute:

docker update[13] --restart=always CONTAINER_ID|CONTAINER_NAME[14]
If the container is started with “--rm” flag, you cannot update the restart policy for it. The AutoRemove and RestartPolicy are mutually exclusive for the container.

See also: docker compose and docker stack

Docker images management[edit]

  • List created images: docker images[15], docker image ls (both commands seems to perform the same action, note it is image instead of images)
Images are stored in docker info | grep "Docker Root Dir"[16]
  • docker image rm[17]. See also: docker rm CONTAINER

Docker Network command line commands[edit]

  • docker network ls
  • docker network inspect

Docker resource limitation[edit]

Docker: Working with remote repositories/registries[edit]

You will be using mainly the following commands docker login, docker logout, docker pull and docker push. Docker registry allow to configure notifications. [18]. Docker has a public repository called Docker Hub and cloud providers offer repositories services such as AWS Elastic Container Registry (ECR).

Docker Information[edit]

Docker Operation[edit]

Docker/cgroup Performance information[edit]

Docker Swarm[edit]


  • docker system prune -a remove unused and dangling images. Therefore any images being used in a container, whether they have been exited or currently running, will NOT be affected.[22]


Docker logging[edit]

Docker support logging to format or different platforms, such as, json-file, syslog, journald, gelf, fluentd, awslogs, splunk, etwlogs, gcplogs and logentries.[24]

docker logs CONTAINER_NAME_OR_ID (Docker Community Engine only support: local, json-file and journald)
docker logs CONTAINER_NAME_OR_ID 2>&1 | grep "STRING_TO_SEARCH" (You will need to redirect outputs to be able to grep output)[25]
See for more information



  1. Read docker blog:
  2. Read Docker Engine release notes (2017) and Docker CE or Docker EE releases.
  3. Understand the difference between an image and a container, Docker Images vs. Containers:
  4. Understand the difference between docker start and docker run: See also runC
  5. Read Stackoverflow questions related to docker:

See also[edit]


  14. docker update --restart=always 90bf248337dc
  21. <