Docker is a containerisation platform-as-a-service (PAAS) that packages an application along with all of its dependencies into a container, making the application work seamlessly in any environment.
I used the term ‘container’ twice in the above line because it’s an important term in the Docker world.
What is a container?
A docker container packages the app, libraries, binaries, and any dependencies so that it can independently run on any system isolated from the host OS.
Since a container eliminates the dependency of the OS, it also eliminates the “...but it works on my machine” problem. I know, you have heard this before.
Containers vs Virtual Machines
A docker container is often compared to a virtual machine because of its similarities but they are a little different.
As mentioned above, a docker container runs on top of the host OS. They do not contain the guest OS unlike the virtual machines – thus making them lightweight. The virtual machines on the other hand sits on top of a hypervisor, which is responsible for running virtual machines and includes its own guest OS – making them consume more resources and comparatively complex.
What is a Docker Image?
A docker image has everything you need to run the application – the code, the libraries, you know the drill by now. But wait, didn’t we said that a container has all of these in it?
An image cannot run on its own. You need to instantiate a docker image as containers to execute them.
In simple words, a static container is an image and a running image is a container.
The reasons why you should move to docker:
It isolates at OS level
The main reason you should move to docker is its ability to package everything you need to run your application into a lightweight container. This helps you to run your application in the same way anywhere without being dependent on the host machine. It provides a consistent environment from development to production which is a huge benefit!
It is better than virtual machines
That is, if you want virtual machines only to run an application. Containers are more light weighted than VMs and can start or stop fairly quickly.
It is highly scalable
With orchestrations systems like Kubernetes or Docker Swarm, it’s easy to manage multiple containers in a network which talk to each other. This really shines in a micro service architecture where loosely coupled systems communicate with each other.
It is layered
One of the first thing I noticed while using docker is its eerie similarity to Git. Each image is made from a base image (we will get to that in the next post) and each commit to an image creates a new layer in the system. A docker image is a series of layers similar to a git branch which is a series of commits.
Docker is an amazing dev-ops tool that can help your application be production-ready without the hassle of machine dependency. Containerisation is the future and it’s already here. Let’s now create our first docker application.
Please subscribe? You’ll only be notified of new posts 🙂