Docker is technically,
An implementation of Container Technology.
Did I just explained one term (Docker) with another term (Container). Well, Lets take a step back and understand that one liner.
First things first,
To understand Container Technology, lets discuss how we used to deploy application on a hardware.
Traditionally we used to,
In above approach we need to install OS on each hypervisor partition which has following drawbacks,
Also, We can’t afford to install 2-3 apps on a single partition
Can we deploy Apps on same OS maintaining Isolated Runtime between them?
Here Container Technology comes to rescue,
Container runs on a thin virtualization on top of Operating System
To understand above definition lets compare it with VM or hypervisor.
VM or hypervisor grabs physical resources like CPU, RAM, storage, networks etc and slices them into virtual versions i.e. virtual CPU, virtual RAM, virtual NICs etc and then builds virtual machines out of them, which feels like normal physical servers.
Container Engines on the contrary, slice operating system resources instead of slicing physical server resources e.g. process namespace, the network stack, storage stack, file system hierarchy etc.
Container act as multiple isolated instances of user spaces on OS sharing a single common kernel
Containers are implemented using two components, viz
Linux Namespaces lets us virtualize system resources e.g. filesystem, networking etc.
In effect, every container gets its own,
Container Runtime is responsible for setting up namespaces and cgroups for containers and then running command inside those namespace and cgroups.
Characteristics of Containers
Enough of containers lets get back to its implementation…
Docker provides a uniform and standard runtime environment where the functionality of an app packed into container remains unchanged whether its running on developers laptop or datacenter or a cloud provider e.g. AWS or Azure.
Internally it uses libcontainers (a pure Go library) as its underlying execution driver (replacing historic LXC driver)
Docker Inc. is the company behind development of docker.
Docker engine/Docker daemon is a standardized runtime environment, that looks and feels the same no matter what platform it’s running on making application portability super simple.
The relation between image and container resembles the relation between program and process i.e.
Container is running instance of Image.
Image in Docker has a concept of Layers, briefly
Union file Systeminto Docker host we can mount a volume from dockerhost into container.
Installing Docker on dev box is super easy,
Once we have installed docker on our favorite dev box (mine being MAC). We can test the installation by,
docker run hello-world
Above command produce following output,
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world d1725b59e92d: Pull complete Digest: sha256:0add3ace90ecb4adbf7777e9aace... Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
Above Console output gives a lot of details. I would like to highlight few among them, lets begin with understanding
Standard Docker install gives us client and daemon on the same host. It’s running the Docker client and the Docker daemon. We’ll often hear that combo referred to as the Docker Engine, sometimes Docker Engine might just refer to daemon part.
When we issue docker run command:
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world
That all folks !!
The intention of this article is to act as brief docker wiki. We tried to touch all the major areas related to docker technology in this brief docker tutorial.