Docker, a tool that can package software into containers that run independently in any environment. So, now what is a container, and for what reasons do you need one?
Let's imagine you built an application with python that runs on a certain distro of Linux. You need to share this application with your friend. However, he has a totally different work setup. So the issue becomes, how would we replicate the environment that our software needs on any machine?
One approach to running this application is with a virtual machine (VM) where the hardware is mimicked and then introduced with the required OS and dependencies. This permits us to run numerous apps on the same hardware. However, because each VM runs on its own operating system, it will be cumbersome and moderate in performance.
Now a Docker container is conceptually the same as a VM with one key difference. As opposed to virtualizing hardware, containers just virtualize the OS. At the end of the day, all apps or containers are controlled by a single kernel, which makes nearly everything quicker and more efficient.
Docker Components
There are three crucial components in the universe of docker - the Docker file, the image, and the container.
1. The Docker file
The Docker file resembles DNA. it's simply a code that advises Docker on how to build an image, which itself is a snapshot of your software alongside the entirety of its dependencies down to the operating system level.
2. The Image
The image is permanent and it very well may be utilized to produce multiple containers, which is your actual software running in the real world.
Create a docker file and use "FROM" to begin from an existing template like ubuntu.
This base image gets pulled down from the cloud and you can likewise transfer your own image to a wide range of docker registries. From that point, you should utilize "RUN" to run a terminal command that introduces dependencies into your image.
You can set environment variables and do a wide range of other stuff as well.
Then the last thing you'll do is set a default command that is executed when you fire up a container.
Now, we can create the image file by running the docker build command.
It goes through each progression in our docker file to build the image layer by layer.
3. The Container
We can then regenerate this image as a container with the docker "run" command.
As your application requests more resources, you can run it on different machines, or different clouds, or any place you need dependably.
This has been "Docker in 1 minute". Β If you appreciated it, try to subscribe and remain tuned for more docker content coming to this blog. Thanks for reading and I will see you in the following one.