- Docker client
It is the external face of docker. User can communicate with docker through the docker client's command interface. Docker client can run in the same host as the docker daemon or it can run in a different host as well. Docker client can connect to a docker daemon through sockets or RESTful API.
- Docker daemon
Backbone of docker containers. It is responsible for building, running and distributing docker containers. User communicate with docker daemon through the client.
- Docker registry
Docker registry holds docker images which are basically a form of read-only template for containers. An Ubuntu operating system with Tomcat and your web application can make up the docker image. Registry can be public or private. Docker hub (https://hub.docker.com) is a public registry provided by Docker and enable people to share their images with others.
To understand how Docker works, one first needs to understand how does a docker image works... In a nutshell, a docker image consists of several layers. Union file systems enable layers to be combined into a single coherent image. As a result of the layering structure, docker images are lightweight and update to the image can easily be applied to a single layer of the image. Therefore, docker images can easily be pulled and pushed in contrast to virtual machines.
Every docker image starts with a base operating system image such as Ubuntu or Fedora. User provided "Dockerfile" includes instructions to specify what additional layers will be added. Each instruction can be an action either running a command, adding a file or directory, creating environment variables or specifying what process to launch when running the container. Each instructions add additional layer to the base image and after each instruction is completed, a final image is generated by Docker.
Docker images are read-only. Containers are built from docker images. When docker runs a container from an image, it adds an additional read-write layer on top of the image, then the application can run.
Docker takes advantage of several Linux kernel features to work seamlessly. "Namespaces" are used to create isolated workspace which docker calls as the container. Docker creates several namespaces including:
- 'pid: process isolation'
- 'net: network isolation'
- 'ipc: inter-process communication namespace'
- 'mnt: mount points'
- 'uts: kernel and version identifiers isolation' namespace
Control groups (cgroups) are used control the resource (max, min) that the container would use. Union file systems is utilized for combining multiple layers in a coherent way.
Docker combines all of these components into a wrapper called container format (libcontainer). Docker also supports Linux containers.
Docker provides couple of tools to optimize and ease the deployment of containers into clusters. These components are:
- Docker Machine: Create and manage machines running docker daemon.
- Docker Swarm: Native clustering capability by turning several Docker engines to a single virtual docker engine.
- Docker Compose: Provides capability to define multi-container applications in a single docker file.
- Docker Registry: Storage and distribution for docker images.
- Docker Engine: Builds and run docker containers.
- Docker Kitematic: UI for managing and docker engines, images and containers.
- Additional Notes
- Some good points in this article (although it's improved later on, so make sure to see second and third part of the article): https://opensource.com/business/14/7/docker-security-selinux
- Users are not namespaced in containers, means that if you run an application as root, then it has all the privileges on host, no isolation for users.
- Suggestions for how to run docker from the above article
- running minimal images: that contains minimum number of services and applications to reduce the attach space.
- using read-only file system: so that no malicious scripts can be downloaded and written.
- limiting kernel calls: with SELinux.
- restricting networking: only linked container communication.
- limiting memory and CPU: with cgroups so as to prevent Denial of service attacks.













