Professional Documents
Culture Documents
Course Guide
Course Guide
History of Virtualization
What is Docker?
Docker Architecture:
Docker Engine
Docker Images
Docker Registries
Docker Containers
Deep Dive Into Docker
History of Virtualization
Earlier, the process for deploying a service was slow and painful. First, the
developers were writing code; then the operations team would deploy it on bare
metal machines, where they had to look out for library versions, patches, and
language compilers for the code to work. If there were some bugs or errors, the
process would start all over again, the developers would fix it, and then again the
operational team was there to deploy.
What is Docker?
Unlike the VMs which can communicate with the hardware of the host (ex:
Ethernet adapter to create more virtual adapters) Docker containers run in an
isolated environment on top of the host's OS. Even if your host runs Windows OS,
you can have Linux images running in containers with the help of Hyper-V, which
automatically creates small VM to virtualize the system's base image, in this case,
Linux.
Docker Architecture
Docker Engine
Docker is the client-server type of application which means we have clients who
relay to the server. So the Docker daemon called: dockerd is the Docker engine
which represents the server. The docker daemon and the clients can be run on
the same or remote host, and they communicate through command line client
binary, as well as a full RESTful API to interact with the daemon: dockerd.
Docker Images
Docker images are the "source code" for our containers; we use them to build
containers. They can have software pre-installed which speeds up deployment.
They are portable, and we can use existing images or build our own.
Registries
Docker stores the images we build in registries. There are public and private
registries. Docker company has public registry called Docker hub, where you can
also store images privately. Docker hub has millions of images, which you can
start using now.
Docker Containers
Containers are the organizational units of Docker. When we build an image and
start running it; we are running in a container. The container analogy is used
because of the portability of the software we have running in our container. We
can move it, in other words, "ship" the software, modify, manage, create or get
rid of it, destroy it, just as cargo ships can do with real containers.
There are some issues that I have listed below with this approach:
1) There is a loss of time and effort.
2) There could be a version mismatch in different setups i.e. the developer &
tester may have installed a verion of tomcat, however the system admin may
have installed a different version of tomcat on the production server.
Using a base image like Ubuntu, which is already existing in Docker Hub (Docker
Hub has some base docker images available for free) . Now this image can be
used by the developer, the tester and the system admin to deploy the tomcat
environment. This is how docker container solves the problem.
This can be done using Virtual Machines as well. However, let’s see a comparison
between a Virtual machine and Docker Container to understand this better.
Virtual Machine and Docker Container are compared on the following three
parameters:
Size
Chart explains how Virtual Machine and Docker Container utilizes the resources
allocated to them.
6 GB of RAM - VM-1,
4 GB of RAM – VM-2,
6 GB to – VM-3.
Using Docker, the CPU allocates exactly the amount of memory that is
required by the Docker Container.
Start-Up
When it comes to start-up, Virtual Machine takes a lot of time to boot up because
the guest operating system needs to start from scratch, which will then load all
the binaries and libraries. This is time consuming and will prove very costly at
times when quick startup of applications is needed.
In case of Docker Container, since the container runs on your host OS, you can
save precious boot-up time. This is a clear advantage over Virtual Machine.
Consider a situation where you want to install two different versions of Ruby on
my system. Using Virtual Machines, you will need to set up two different Virtual
Machines to run the different versions. Each of these will have its own set of
binaries and libraries while running on different guest operating systems.
Whereas if I use Docker Container, even though you will be creating two different
containers where each container will have its own set of binaries and libraries,
you will be running them on the same host operating system. Running them
straight on the Host operating system makes my Docker Containers lightweight
and faster.
So Docker Container clearly wins again from Virtual Machine based on Startup
parameter.
Integration of different tools using Virtual Machine maybe possible, but even that
possibility comes with a lot of complications.
You may have only a limited limited number of tools running in a Virtual Machine.
If you want many instances of these tools, then you would need to spin up many
Virtual Machines because each one of them can have only one running instance of
them. Setting up each VM brings infrastructure problems with it.
This is where Docker comes to the rescue. Using Docker Container, we can set up
many instances of applications and tools, all of them may be running in the same
container or running in different containers, which can interact with one another
by just running a few commands. You can also easily scale up by creating
multiple copies of these containers. So configuring them is not be a problem.
This Docker Toolbox is an installer to quickly and easily install and setup a Docker
environment on a host. In the case of Windows there is an additional Docker
Toolbox component required inside the Docker host. Docker Toolbox installs
Docker Client, Machine, Compose (for MacOS only), Kitematic and VirtualBox.
Let’s now revew three important terms, i.e. Docker Images, Docker
Containers and Docker Registry.
Docker Image
You can either use a ready-made docker image from docker-hub or create a new
image as per your requirement.
Docker Container
Containers are the ready applications created from Docker Images or you can say
a Docker Container is a running instance of a Docker Image and they hold the
entire package needed to run the application. This happens to be the
ultimate utility of Docker.
Docker Registry
Finally, Docker Registry is where the Docker Images are stored. The Registry can
be either a user’s local repository or a public repository like a Docker Hub
allowing multiple users to collaborate in building an application. Even with
multiple teams within the same organization can exchange or share containers by
uploading them to the Docker Hub. Docker Hub is Docker’s very own cloud
repository similar to GitHub.
There are several dockers commands .. we will talk more about that later.
Command Description
Containers have no guest OS and use the host’s operating system. So,
they share relevant libraries & resources as and when needed.
Processing and execution of applications are very fast since applications
specific binaries and libraries of containers run on the host kernel.
Booting up a container takes only a fraction of a second, and also
containers are lightweight and faster than Virtual Machines.
Now that you have understood what containerization is and the reasons to use
containers, let us cover other terms and concepts.
- Docker Compose & Docker Swarm
Docker Compose is a YAML file which contains details about the services,
networks, and volumes for setting up the Docker application. So, you can use
Docker Compose to create separate containers, host them and get them to
communicate with each other. Each container will expose a port for
communicating with other containers.
Summary: