Docker
Problem
Traditionally, installation of software requires a lot of steps namely,
Downloading the software package/installer for your specific platform.
Run the package/installer.
Troubleshoot issues if any like missing dependencies (i.e download all the dependencies), dependency version conflicts etc rerun the installer and go through the loop untill all the issues are resolved.
Finally after all the issues are resolved may be the software might be running in your specific environment.
Want to install in a different machine with different configuration? Start from step 1 again and again go through painstaking troubleshooting process, just to get the software installed.
Solution
This is where docker comes to rescue.
With Docker, installation and managing software becomes breeze.
Just install docker for your machine and use the commandline/docker file/docker-compose to spin up the container for your software.
No environment specific setup would be needed from hence forth to install softwares, as docker images handles them for you.
About
Docker is an open platform for developing, shipping, and running applications.
It was first released in 2013 and is developed by
Docker, Inc
.Docker is a tool that is used to automate the deployment of applications in lightweight containers so that applications can work efficiently in different environments in isolation.
Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.
Terminology
Image
Container
Namespace
A feature of the Linux kernel that partition kernel resources such that one set of processes sees one set of resources, while another set of processes sees a different set of resources
cgroup
A Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, etc) of a collection of processes
Docker Platform
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.
Docker provides the ability to package and run an application in a loosely isolated environment called a container.
The isolation and security lets you run many containers simultaneously on a given host.
Containers are lightweight and contain everything needed to run the application, so you don't need to rely on what's installed on the host. You can share containers while you work, and be sure that everyone you share with gets the same container that works in the same way.
Components
Docker Client
Tool that we are going to use to issue the command, which will be executed by Docker Server
Docker Server (Daemon)
Tool that runs behind the scene, which is responsible for creating images, running container etc
Docker Working
When you run a
docker run
command the following are the series of steps that ensue,Docker cli processs the command and sends the command to docker server/daemon running in the machine.
Docker Server looks for the image in the image cache.
If the image is found in the cache it executes the image and spin up a container.
If the image is not found, it communicates to the docker hub (a public repositories with docker images) and looks for the image with version specified or latest version if no version is specified and downloads them and puts them in its local cache and executes them.
Docker Setup in non-linux machine
Port Mapping
An application running within a container cannot access ports of the host in which it has the docker container running.
Container basically has its own isolated set of ports.
So, when any incoming traffic tries to access a port of the container it will be blocked as the container runs in an isolated environment.
To solve this problem we use the port mapping functionality of the docker, which will basically forward the traffic received at the host to port of the container.
Outgoing traffic from the container to the outside world is allowed and need no extra configuration.
References
Last updated