Skip to content

Fundamental Concept

The basis for containers are so-called images, a simple file that eliminates the need to install and update software. Images contain all the components needed to run an application platform-independently. Thus, an image can be transferred to another system only by a simple copy process. The container can then be started from the image.

Images are made available via a registry, which stores, manages and provides them. The most well-known public Registry is Docker hub.

In addition, we can build our docker images with so-called Dockerfile. A Dockerfile is a simple text file. It describes the structure of a Docker Image.

Docker on Linux

The Docker engine is doing the following actions on multiple containers: * produces * monitors * manages

The Docker engine is built on top of the Linux kernel and it extensively leverages its features. for example under Ubuntu It can be installed with the follwoing command:

$ sudo apt-get install -y docker.io

Docker on Windows

The Docker engine could be run on the Mac and Microsoft Windows operating systems by using the lightweight Linux VMs with the help of adapters, such as Boot2Docker, or using the docker desktop.

Docker Desktop (Windows and Mac)

Docker Desktop is a popular way to configure a Docker dev / test environment. It eliminates the “it worked on my machine” problem because you run the same Docker containerized applications in development, test, and production environments. It exists on both Windows and Mac. It includes Kubernetes

Source: Docker Blog

Docker version

The client and server of docker each has its own version nad can be asked by version command as follows:

Client: Docker Engine - Community
    Version:            19.03.5
    API version:        1.40
    Go version:         go1.12.12
    Git commit:         633a0ea
    Built:              Wed Nov 13 07:22:37 2019
    OS/Arch:            windows/amd64
    Experimental:       false
Server: Docker Engine - Community
  Engine:
    Version:            19.03.5
    API version:        1.40 (minimum version 1.12)
    Go version:         go1.12.12
    Git commit:         633a0ea
    Built:              Wed Nov 13 07:29:19 2019
    OS/Arch:            linux/amd64
    Experimental:       false
  containerd:
    Version:            v1.2.10
    GitCommit:          b34a5c8af56e510852c35414db4c1f4fa6172339
  runc:
    Version:            1.0.0-rc8+dev
    GitCommit:          3e425f80a8c931f88e6d94a8c831b9d5aa481657
  docker-init:
    Version:            0.18.0
    GitCommit:          fec3683     

First Steps

For downloading an image from a registry we can use pull command.

$ docker pull busybox 
   Using default tag: latest
   latest: Pulling from library/busybox
   bdbbaa22dec6: Pull complete
   Digest: sha256:6915be4043561d64e0ab0f8f098dc2ac48e077fe23f488ac24b665166898115a
   Status: Downloaded newer image for busybox:latest
   docker.io/library/busybox:latest
$ docker images 
   REPOSITORY   TAG IMAGE ID        CREATED     SIZE
   Busybox      latest  6d5fcfe5ff17    3 weeks ago             1.22MB
$ docker run busybox echo "Hello World!" 
   "Hello World!" 

BusyBox

It is the Swiss Army Knife of Embedded Linux.

BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.

BusyBox has been written with size-optimization and limited resources in mind. It is also extremely modular so you can easily include or exclude commands (or features) at compile time. This makes it easy to customize your embedded systems. To create a working system, just add some device nodes in /dev, a few configuration files in /etc, and a Linux kernel.

BusyBox is maintained by Denys Vlasenko, and licensed under the GNU GENERAL PUBLIC LICENSE version 2.

Alpine

The follwoing diagram show an example of a running an alpine container. * Step 1: we call docker run follwing by name of image and then the command which must be run there. * Step 2: the docker engine create the container from the image and run the requested command inside that. * Step 3: the container will be shut down.

Alpine Linux is a Linux distribution based on musl and BusyBox, designed for security, simplicity, and resource efficiency. It used a hardened kernel until release 3.8 and compiles all user-space binaries as position-independent executables with stack-smashing protection. Because of its small size, it is commonly used in containers providing quick boot-up times.

Exercise

run the following commands and explains what they do.

$ docker pull busybox
$ docker images
$ docker run busybox
$ docker run busybox echo "hello from busybox"