Docker a tool that can package software into containers that run reliably in any environment, but what is a container and why do you need one?
Let’s imagine you built up an app with cobalt that runs some weird flavor of Linux. You want to share this app with your friend but he has an entirely different system, so the problem becomes how do we replicate the environment (that) our software needs on any machine.
One way to package an app is with a virtual machine where hardware is simulated then installed with the required OS and dependencies.
This allows us to run multiple apps on the same infrustructure, however because each VM is runnning its own operation system, they tend to be bulky and slow.
Now a docker container is conceptually very similar to VM with one key difference. Instead of virtualizing hardware, containers only virtualize the OS, or in other words all apps or containers are run by single Kernel and this makes almost everything faster and more efficient.
There are three fundamental elements in the universe of docker: dockerfile, image and container.
The dockerfile is like DNA, it’s just code that tells docker how to build image which itself is a snapshot of your software along with all of its dependencies down to the operationg system level.
The image is immutable and and can be used to spin up multiple containers which is actual software runnng in the real world.
Create a docker file and use from to start from an existing template like ubuntu, this base image gets pulled down from the cloud and you can also upload your own images to a variety of different docker registries.
From there you might want to use run to run a terminal command that installs dependencies into your image.
You can set environment variables and do all kinds of other stuff, then the last thing you’ll do is set a default cmmand.
That’s ececuted when you start up a container, and now we can create the image file by running the docker build command/
It goes through each step in our docker file to build the image layer by layer. We can then bring this image to life as a container with the docker run command.
As your app demands more resources, you can run it on multiple machines, clouds, on-prem or whereever you want reliably. This has been docker in 100 seconds, if you enjoyed,