Docker is what most of us look up to when it to Containers, right? There definitely seems to be no contradiction on this at least. Even though Containers are not VM replacements, the companies have started to utilize it in that way. Docker uses a client-server architecture. In this blog, I will be covering everything you have to know about the Architecture & Components of the Docker and Container lifecycle.

What Is Container (Docker)?

Containers are a software package into a logical box with everything that the application needs to run. That includes the operating system, application code, runtime, system tools, system libraries, and etc. Docker containers are built off Docker images. Since images are read-only, Docker adds a read-write file system over the read-only file system of the image to create a container.

Containers are compared with virtual machines (VMs). VMs are the guest operating system such as Linux or Windows runs on top of a host operating system with virtualized access to the underlying hardware. Containers allow you to package your application together with libraries and other dependencies, providing isolated environments for running your software services.

Different Container Providers

Also check: All you need to know on Containers

What is Docker?

Docker is an open-source platform based on Linux containers for developing and running applications inside containers. Docker is used to deploy many containers simultaneously on a given host. Containers are very fast and lightweight because they don’t need the extra load of a hypervisor as they run directly within the host machine’s kernel.

Docker Architecture and Components

Docker uses a client-server architecture. The docker client talks to the Docker daemon, which used to building, running, and distributing the Docker containers. The Docker client and daemon communicate using a REST API, over UNIX sockets, or a network interface.

There are five major components in the Docker architecture:

a) Docker Daemon listens to Docker API requests and manages Docker objects such as images, containers, networks and volumes.

b) Docker Clients: With the help of Docker Clientsusers can interact with Docker. Docker client provides a command-line interface (CLI) that allows users to run, and stop application commands to a Docker daemon.

c) Docker Host provides a complete environment to execute and run applications. It comprises of the Docker daemon, Images, Containers, Networks, and Storage.

d) Docker Registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to use images on Docker Hub by default. You can run your own registry on it.

e) Docker Images are read-only templates that you build from a set of instructions written in Dockerfile. Images define both what you want your packaged application and its dependencies to look like what processes to run when it’s launched.

Also Read: Our previous blog post on Docker Tutorial. Click here

Resource Isolation In Container (Docker)

a) Namespace provides a layer of isolation. namespace limits what you can see. When we run a container, Docker creates a set of namespaces for that container. There are different types of namespace pid, net, mnt, uts, ipc.

b) Control groups limit an application to a specific set of resources. it limits how much resources you can use. This allows the Docker Engine to share available hardware resources to containers and optionally enforce limits and constraints.

c) Union file systems that operate by creating layers, Docker image is made up of filesystems layered over each other making it very lightweight and fast.
If you didn’t have UnionFS, a 200MB image runs 5 times as 5 separate containers would mean 1GB of disk space.

Also Read: Our blog post on Docker Image Vulnerability Scanning. Click here

Docker Engine Components

Docker Engine is the layer on which Docker runs. It is installed on the host machine. It’s a lightweight runtime and tooling that manages containers, images, builds, and more.

There are three components in the Docker Engine:

a) Server: It is the docker daemon called dockerd. It can create and manage docker images, i.e, Containers, networks.

b) Rest API: It is used to instruct docker daemon what to do.

c) Command Line Interface (CLI): It is a client that is used to enter docker commands.

Docker Networking and Docker Storage

Networking in Docker is part of docker which is used to connect the docker container to each other and outside world so they can communicate with each other also they can talk to Docker Host. you can connect docker containers to non-Docker workloads. Docker uses  Container Network Model (CNM) for networking.

Note: Also read our blog on Docker networking

Docker Storage: By default, all files created inside a container are stored on a writable container layer so the data doesn’t persist when that container no longer exists. Docker has two options for containers to store files in the host machine, so that the files are persisted even after the container stops: volumes, and bind mounts.

Storage in Docker has a lot more to learn from, do go through our Docker storage blog.

Docker Container Lifecycle Management

There are different stages when we create a container which is known as Lifecycle of container i.e create, run, pause, delete & stopped.

  • The first phase is the created state. Further, the container moves into the running state while we use the Docker run command.
  • We can stop or pause the container, using Docker stop/pause command. And, to put a container back from a stopped state to a running state, we use the Docker run command.
  • We can delete a running or stopped container, using Docker rm command.

Note: Docker Lifecycle is a really interesting concept, check out Docker Lifecycle post which covers everything in detail.

Leave a Reply

Your email address will not be published. Required fields are marked *