Skip to content

Quick overview about Docker

Docker is an open source technology to run, deploy and create apps using containers. A container is a runtime instance of a previously created image. It contains everything a certain app needs for its execution like code, libraries, environment variables and other settings. The image is the static packaged app, which will become a container as soon as the image is run on the Docker Engine.

The IED contains a preinstalled Linux-based operating system and Docker, which enables all the capabilities of containerization. All the advantages of containerization against virtual machines can be used. Docker and Containers enable lightweight, portable, scalable, and rapid development. A VM always contains a hardware abstraction layer as well as a own operating system. A Docker container is sharing the host's kernel. The differences are shown in the following figure stack overview of container and virtual machine.

Picture_2_2_Docker_VM_Comparison

Ready-made images can be obtained from Docker Hub. From these images own containers can be derived to work with. It is also possible to combine multiple containers to a group with docker-compose.

The predefined images will mostly fit the requirements. The essential work for configuration, additional package installation or other settings can be done manually each time or be automated. To automate it, an own image is created. The required changes are done in a file called Dockerfile. With this Dockerfile it is possible to create an own local image after calling docker build.

The procedure of creating a new image is done as follows. Create an own directory with the Dockerfile. Inside this file you can specify with instructions attributes for the image. docker build is creating the local image. Afterwards it is possible to publish the image to a public Docker-repository (Docker Hub) or a private Docker repository.

For more information about the Dockerfile syntax and best practices please have a look at https://docs.docker.com/engine/reference/builder/ and https://docs.docker.com/develop/develop-images/dockerfile_best-practices/.

To provide the images please refer to https://docs.docker.com/docker-hub/builds/ and https://docs.docker.com/registry/.

The container setup can be done by docker-compose. The command will evaluate the text file docker-compose.yml in the current directory and configures the container depending on the content. It is a practical way to combine multiple containers in a single setup.

The YAML-Syntax of the yml-file contains some rules:

  • --- initiates a new section
  • # starts a comment, till end of the line
  • Strings are expressed with “ or '. It is only necessary in special cases if the string contains special character or YAML expressions
  • Multiple expressions starting with – are together a list.
  • Key-Value pairs are written in key: value.
  • | starts a text block, which can contain line breaks.
  • > starts a text block, line breaks are ignored only empty lines are maintained

There are more expression available but for the docker-compose.yml the listed ones are sufficient.

To validate YAML files you can use online validators like http://www.yamllint.com/ or https://codebeautify.org/yaml-validator.

The docker-compose.yml file starts with the docker-compose file format version number. This version number describes which features can be used. After the version number the service keys configure the services. Then every service starts with an indented self-defined name. These services contain again indented key words to describe the service. The structure of a docker-compose.yml can be seen below:

# Basic structure of a docker-compose.yml

version: "2.4"
services:
 serviceName1:
  keyWord1: setting1
  keyWord2: setting2
  ...
 serviceName2:
  ...
 ...

Reference Docker-Compose

A complete reference about docker-compose.yml and its key words can be found under https://docs.docker.com/compose/compose-file/. This section is only explaining Docker essentials for the Industrial Edge environment. If you want to know more about Docker, we recommend an online training course like e.g. Pluralsight or LinkedIn Learning.