What is Docker?
A quick summary and intro (simplified)
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 we build an app with Cobol that runs on 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 our software needs on any machine?
One way to package an app is with a virtual machine, where the hardware is simulated, then installed with the required OS and dependencies. This allowed us to run multiple apps on the same infrastructure, however, because each VM is running its own operating system, they tend to be bulky and slow. Now a Docker container is conceptually very similar to a VM with one key difference: instead of virtualizing hardware, containers only virtualize the os. In other words — all apps or containers are run by a single kernel. This makes almost everything faster and more efficient.
There are three fundamental elements in the universe of Docker. The Docker file, the image and the container. The docker file is like DNA, it’s just code that tells Docker how to build an image, which itself is a snapshot of your software along with all of its dependencies down to the operating system level. The image is immutable and it can be used to spin up multiple containers which is your actual software running in the real world.
Create a docker file and use ‘from’ to start from an existing template like Ubuntu. The base image gets pulled down from the cloud and you could also upload your own images to a variety of different docker registries. From there, you may want to use ‘run’ to run a terminal command that installs dependencies in your image. You can set environment variables and do all kinds of other stuff. The last thing you’ll do is set a default command that’s executed when you start up a container. Now, you can create the image file by running the docker build command. It will go 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, multiple clouds, on-prem, or wherever you want reliably.
I hope this short intro helps to introduce the fundamental idea of Docker and how it is useful!