Docker Zero to Hero

Part I — Introduction to Docker

Lakshitha Fernando
5 min readMay 19, 2021
Docker for absolute beginners
Introduction to Docker

This is the first of the Docker series and following areas will be covered in this article.

  • What is Docker?
  • Why Docker?
  • Docker Architecture
  • Docker Hub
  • Docker File
  • Image vs. Container

| What is Docker

Docker is an opensource platform developed to create, deploy and execute container based applications.

Yes, let’s discuss what is a container based application.

Container

Containers — https://www.thesafetymag.com/

Container is a package which consists all the necessary libraries and configurations to run an application. This is a portable artifact which could be easily shared among different environments.

Example:

Lets assume that you have developed an application which has to be configured based on its hosting environment. (Linux, Mac OS etc.) So when the application is deployed in each environment, it is needless to say that the amount of effort, time and the expertise knowledge required for a successful deployment.

But when the application is containerized (developed and assembled as a container with all the necessary configurations and dependencies),it can be easily installed with a single command in any environment.

Redis Container

| Why Docker

Docker is a virtualization tool as the Virtual Machine (VM). But the main difference between VM and the Docker is the level of virtualization.

Docker vs. VM

As you see in the above image, Docker virtualizes only the application whereas the VM does it with both application and OS level. Due to this Docker images are much smaller in size and containers can quickly start and run the application.

The downside of the Docker container is, you cannot install a Linux based container on a different operating system. Microsoft has introduced Windows Subsystem for Linux (WSL) 2 on Docker desktop which allows Linux containers to run natively without emulation on Windows.

| Docker Architecture

Docker implements a client-server architecture compromising the Client, Host, Registry/Repository. We will discuss each element in detail.

Docker Architecture
Docker Architecture — https://www.researchgate.net/

Docker Client

Docker client acts as an interface for users to issue commands to Docker Daemon via Command Line Interface (CLI). Below is few of the most widely used Docker commands.

docker run
docker pull
docker push
docker build

Docker Host

Provides the environment to execute and run Docker containers. Docker Host contains Images, Containers, Networks and Storages. Docker Daemon is implemented in the host which actively listens to Docker API requests which comes from the Client.

Docker Daemon

A persistent background process that handles images, container, storage volumes and networks while constantly listening to Docker API. Docker Daemon is a part of the Engine and that is capable of communicating with other daemons to manage Docker services.

Docker Registry

Registry is a stateless service that is responsible for hosting and distributing images.
Example : Docker Hub, Google Container Registry, AWS Container Registry

Docker Repository

A place where you can publish different versions(tags) of the same image. A repository could be either private or public.

| Docker Hub

Docker Hub is the public repository for Docker containers where one can create his own containers and push to Docker Hub where anyone can access. There are thousands of verified publishers have pushed their containers to Docker Hub and you can install any of them with a simple command to your local environment.

| Docker File

Docker file is a text document that contains all the commands to build an image. Below is a sample docker file. We will create our own docker files in an upcoming post.

DockerFile
DockerFile — https://miro.medium.com/

| Docker Image vs Container

Docker Image

Docker image is created from multiple Docker layers and each layer represents an instruction of the Docker file.

Docker Layer

As we discussed, Docker layer is an image layer build up from an instruction of the Docker file. These layers are immutable and stacked on top of each layer and depends on the layer immediately below it. The advantage of these layering is when a change happen to some instructions in the Docker file, Docker does not rebuild all but only the required layers to build the new image. This is called Docker Caching.

When a Docker image is launched using a container, a thin writable layer is added on top of the image layers called Container Layer which maintains its own state so that any number of containers can share and access the underlying image.

Docker Image Layers
Docker Image Layers — https://docs.docker.com/storage/storagedriver/

Docker Container

Container is an encapsulated environment for Docker image which expose certain properties so that Docker Daemon can communicate with the image. One image could be shared among multiple containers with different port bindings.

In the next post we will discuss how to download Docker images from Docker Hub and run it as containers in your local environment.

Stay in touch !!

References :

--

--

Lakshitha Fernando
Lakshitha Fernando

Written by Lakshitha Fernando

Technical Lead at Camms. A graduate of University of Colombo School of Computing Sri Lanka. Microsoft certified programmer | Traveller | Hiker and Bookworm

No responses yet