Thursday 3 March 2016

Dockers: Part 1 - Basic Components

Docker is an open-source engine that automates the deployment of applications into containers.
Docker architecture:
  1. Docker uses a client/server architecture.
  2. "docker daemon" is server and responsible for build/run and distribute your docker containers.The user can not directly interact with the daemon, but instead through the Docker client.
  3. "docker" is a command line client binary which talks to docker daemon. It accepts commands from the user and communicates back and forth with a Docker daemon
  4. The Docker client and daemon communicate via sockets or through a RESTful API.
  5. Docker daemon and client can be run on same machine or two different machines.
NOTE: Single binary, docker, acts both as a server daemon and client.

Docker images:
  1. It is "build" component of docker. It can be considered as read-only templates for docker containers.
  2. Images are built step-by-step using a series of instructions  like
    a. ADD file
    b. RUN command
    c. Open port
  3. You can build new images, updates existing one or download images which people already has created.
  4. You launch your containers from images.

Docker Registries:
  1. It is "distribution" component of Docker platform.
  2. You can have public/private registries.
  3. Public docker registry is provided with the Docker Hub. It serves a huge collection of existing images for your use.
  4. You can upload/download Docker images to/from these registries.

Docker Containers:
  1. It is "run" or "execution" component of docker. 
  2. Containers are created from Docker images. 
  3. You can create multiple containers from single image.
  4. Containers can be run, started, stopped, moved, and deleted.
  5. Each container is an isolated and secure application platform.

Summary:
  1. You can build a Docker images that hold your applications.
  2. You can create a docker containers from those Docker images to actually run your applications.
  3. You can share those Docker images via Docker Hub or your own registry.

How Docker images work?
  1. Each docker image starts from a base image (Ubuntu, Fedora etc).
  2. Further construction is done using simple, descriptive set of steps called instructions.
  3. Instructions are stored in a file called DockerFile. Docker reads this file and execute instructions to construct and returns the final image.
  4. Instruction include actions like ADD, COPY, RUN etc.
  5. Each instruction creates a new layer in our image. 
  6. Docker makes use of Union File System to create the final image.
  7. That final image tells Docker what the container holds, what process to run when the container is launched, and a variety of other configuration data
How does container work?
  1. The Docker image is read-only. When Docker runs a container from an image, it adds a read-write layer on top of the image (using a union file system as we saw earlier) in which your application can then run.

No comments:

Post a Comment