Understanding docker architecture

What is docker

To understand docker let us use a powerful metaphor rather than a technical explanation. Dockers are laborers who moved containers into and out of ships docked into different ports. This might sound familiar to anyone working in software as a huge amount of time and energy is spend in transporting different applications to different metaphorical ships(dev servers, production servers). So they can be used to solve different businesses problems.

Figure shown below explains how docker can be used to save time and money, without docker a lot of time and energy is required to configure and run different application in different environments. With docker this process can be simplified with docker run command, to pull down environment’s image and ready to run. You don’t have to worry about your container is going to ship on on redhat or centos server, as long it has docker it will be good to go.

Key docker commands

Docker main functionality is to build run and ship softwares in any any environment that has docker, like git or any other version control system docker has many commands and subcommands. So to the end user docker is a command line program that they run.

main docker commands

Docker container and image is a concept similar to a process and a program, like process is a program in execution. Docker image can be seen as an image in execution.

Docker Architecture

Docker on your host machine is mainly divided into parts Docker daemon with a set of rest APIs and a docker client to interact with daemon. This can be viewed as a client server architecture in which client requesting for resources or orchestrating with commands and the server daemon responding.

Docker architecture

A docker registry is a service docker images can be stored. Private docker registry is a a service that is accessible only on internal network while a public docker repository can be accessed from anywhere. Dockerhub is a service made available by Docker Inc to store docker images.

The Docker Daemon

The docker daemon is the center point of interaction with docker. manages state of containers and interactions with the outside world.

Docker daemon

Now let’s see some techniques used to run docker as a daemon.

  • Techinque-1 Open your docker daemon to the outside world

Before you open up the Docker daemon, you must first shut the running one down

sudo service docker stop

Once the Docker daemon has been stopped, you can restart it manually and open it up to outside users with the following command

sudo docker daemon -H tcp://

Although by default docker daemon can only be accessed locally sometimes there might be good reason to access daemon remotely (for example you want someone to debug remotely)

  • Technique-2 Running docker daemons as containers

This enables you to start docker containers as background service. The -d flag, when used with docker run, runs the container as a daemon. The -i flag gives this container the ability to interact with your Telnet session. With -p you publish the 1234 port from the container to the host.

docker run -d -i -p 1234:1234 --name daemon ubuntu:14.04 nc -l 1234

The Docker Client

The docker client is what you run when, when you run commands like docker run, docker pull etc. It’s job is to communicate via docker daemon via HTTP requests.