An introduction to Docker

3 minute read

Published:

Topics: Docker

I have been wanting to learn more about Docker for months. However, when starting to read Dockers get started page I quickly had to find out that I’m lacking knowledge in too many other concepts. Since my background isn’t computer science I often run across this problem. Luckily, this allows me to constantly learn new things! After writing a post on virtual machines and another about containers this one is finally about Docker!

Docker

What is Docker?

Docker is a tool that makes it easy to use containers. We already learned that containerization allows us to package an application and all its dependencies into a little box - the container - which can then run anywhere. This allows developers to be sure that their software will run independently of where it is deployed.

Of course, there were other technologies for containerization before Docker. However, Docker made it much easier and also safer to deploy containers than previous approaches. Another major benefit of Docker is that it’s open source. This means that anyone can contribute to Docker and that Docker can be customized to one’s own needs.

How Docker works

A basic Docker architecture consists of three major parts:

  1. Docker daemon (dockerd)
    The Docker daemon is responsible for creating, running, and monitoring Docker objects like containers or images. It can communicate with other daemons to manage Docker services. Usually, the daemon is launched by the host operating system.

  2. Docker client (docker)
    The Docker client talks to the Docker daemon. For most people, the Docker client is the main way to interact with Docker. When calling commands like docker run, the Docker client sends them to the Docker daemon, who carries out the commands. It’s also possible to interface directly with the daemon without using the Docker client.

  3. Docker registries
    A registry stores and distributes Docker images. The big public registries are Docker Hub and Docker Cloud and can be used by anyone to pull or push publically available images. You can also run your own private registry. However, by default docker pull, docker push and docker run commands will look for the required images on Docker Hub.

Link to image if you can’t see it displayed here

Docker objects

When using Docker we create and use different kinds of objects, for examples images, containers, networks or plugins. Images and containers are the most important objects, so let’s take a closer look at them. For more details on containers, take a look at the blog post on containers.

Images

  • Template that contains instructions for creating a Docker container
  • We can create our own images or use those created by others and published in a registry
  • To create an image we first have to create a Dockerfile
  • The Dockerfile defines the steps required to create and run the image

Containers

  • Runnable instance of an image
  • A container is defined by its image and the configuration options that we provide when creating or starting the container
  • To learn more about containers, look at the corresponding blog post

Sources