DevOps/Docker

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

Features
Docker offer the following features:
 * Package an application and its dependencies in a virtual container that can run on any Linux server (/docker images/)
 * Pull or push /docker images/ to a container repository/container registry . By default docker hub but you can specify any other registry.

Installing Docker
You can read official Docker documentation about installing Docker on your system: https://docs.docker.com/install/.

On macOS you can follow official documentation https://docs.docker.com/docker-for-mac/install/ which requires to create and account to download installer. You can also try: or try to follow https://pilsniak.com/how-to-install-docker-on-mac-os-using-brew/ instructions:
 * (to install docker and docker-compose)
 * (will pull hello-world image and run it on docker)
 * (will pull hello-world image and run it on docker)
 * (will pull hello-world image and run it on docker)
 * (will pull hello-world image and run it on docker)
 * (will pull hello-world image and run it on docker)
 * (will pull hello-world image and run it on docker)

On Ubuntu:

Binaries
Following binaries will be installed:,  ,   and

Verifying Docker installation
Once installed the Docker daemon, called  should be running. You can also run  to verify docker correct installation.

Configuration files

 * Ubuntu:

Docker Releases (/Docker Engine release notes/)
Use: to check your version. You can download Docker CE source code from GitHub.
 * https://docs.docker.com/engine/release-notes/
 * https://github.com/docker/docker-ce/releases

Docker Command Line
You can read official docker command line documentation in https://docs.docker.com/engine/reference/commandline/docker/. Before being able to run docker commands you will have to install Docker on your machine.

Some typical task using containers:

Docker verification commands
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
 * Verify correct installation:

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. (amd64) 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: https://cloud.docker.com/

For more examples and ideas, visit: https://docs.docker.com/engine/userguide/

Docker image and container creation

 * Create a new docker image base on alpine linux distribution and login into the new container:
 * Create a new docker image:
 * Create a new docker image by creating a new text file with instructions, usually called :
 * Create a container:
 * Generate a mediawiki:1.27 image:  (you can use -t or --tag)
 * Execute or run a container based on mediawiki:1.27 image:

Docker Container Operation

 * Start an existing container: . See also /docker run/ and differences.
 * Stop an running container:


 * Show only running containers:
 * or  .  introduced in 2017 in Docker 1.13 (There is no difference between both commands)


 * Show containers (running or not):
 * : https://docs.docker.com/engine/reference/commandline/ps/
 * . See also


 * Login/Connect into a running container:


 * Start stopped containers:
 * Restart all containers:  previously


 * /Start configuration behavior and restart policy/

See also: docker compose and

Docker images management

 * List created images:,   (both commands seems to perform the same action, note it is image instead of images)
 * Images are stored in


 * . See also:

Docker Network command line commands

 * Deprecated:
 * Deprecated:
 * Deprecated:

Docker resource limitation

 * Limit container CPU usage to 0.5 cpus:
 * Limit memory requires your kernel to have functionality activated, you can check it executing . See https://docs.docker.com/install/linux/linux-postinstall/ and docker-compose resource limitation example: DevOps/Docker/docker compose/Version 3 resouces

Docker: Working with remote repositories/registries
You will be using mainly the following commands,  ,   and. Docker registry allow to configure notifications. . Docker has a public repository called Docker Hub and cloud providers offer repositories services such as AWS Elastic Container Registry (ECR).

Docker Information

 * https://docs.docker.com/engine/reference/commandline/version/
 * https://docs.docker.com/engine/reference/commandline/info/
 * https://docs.docker.com/v17.12/edge/engine/reference/commandline/system_info/
 * https://docs.docker.com/v17.12/edge/engine/reference/commandline/system_events/
 * https://docs.docker.com/engine/reference/commandline/top/
 * https://docs.docker.com/engine/reference/commandline/inspect/ also available for: container, image, volume, network, node, service, or task
 * or
 * https://docs.docker.com/engine/reference/commandline/inspect/ also available for: container, image, volume, network, node, service, or task
 * or
 * or
 * or

Docker Operation

 * : https://docs.docker.com/engine/reference/run/
 * : https://docs.docker.com/engine/reference/commandline/start/
 * : https://docs.docker.com/engine/reference/commandline/stop/
 * : https://docs.docker.com/engine/reference/commandline/restart/

Maintenance

 * 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.

Volumes

 * : https://docs.docker.com/engine/reference/commandline/volume/
 * : https://docs.docker.com/engine/reference/commandline/volume_ls/

Docker logging
Docker support logging to format or different platforms, such as, json-file, syslog, journald, gelf, fluentd, awslogs, splunk, etwlogs, gcplogs and logentries.
 * Configuration is done at docker container start time with command
 * Check method configured in a running container:
 * View logs
 * (Docker Community Engine only support: local, json-file and journald)
 * 2>&1 | grep "STRING_TO_SEARCH" (You will need to redirect outputs to be able to grep output)
 * See https://docs.docker.com/config/containers/logging/ for more information
 * 2>&1 | grep "STRING_TO_SEARCH" (You will need to redirect outputs to be able to grep output)
 * See https://docs.docker.com/config/containers/logging/ for more information

Activities

 * 1) Read docker blog: https://blog.docker.com/
 * 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: https://stackoverflow.com/a/26960888
 * 4) Understand the difference between   and  : https://stackoverflow.com/questions/34782678/difference-between-running-and-starting-a-docker-container. See also runC
 * 5) Read Stackoverflow questions related to docker: https://stackoverflow.com/questions/tagged/docker?tab=Votes