Let’s look at Docker using an example of making burgers! Imagine being very popular among friends and family because you make delicious and consistent burgers. It just has the same deliciousness every single time. So far, you make burgers at your home, and you know exactly what you need, and you are so used to making it that you create that exact taste every single time. Until now, you are happy, and you won’t have to worry about the concepts of docker because your burgers still provide the same taste every time your friends want from the comfort of your home.
Now, let's complicate your scenario a little more; you have been invited to a picnic far away from your home and requested to make 10 burgers for multiple people at the picnic. Your friends are expecting that you will be able to deliver the unique taste that you have been delivering when they visit your home. The challenge for you is getting the same ingredients and proportions. So, you ask yourself, “Will I be able to find the same quality lettuce, the same quality tomatoes, or the meat patties?” These are very valid questions because if you don’t get the ingredients you usually depend on, your burger may taste a bit different, which your friends may not prefer, simply because they are expecting the same taste from before. And this could be a problem!
To remediate the issue, you could prepare ingredients beforehand for the 10 burgers you planned to make at the picnic and take them with you. For each burger, you packed the buns, lettuce, patties, tomatoes, onions, cheese, and condiments. This way, you can guarantee that there would be no change in the taste regardless of where you go and make the burgers. And there you go, my friends, you just learned docker.
Docker ensures that everything you need is packed together so that when you run your app, it does not have to look for items it needs to run. It is packaged so that no matter where you run it, all its pieces are ready there, providing the same experience every single time.
Just like how a set of ingredients make up a burger, a set of dependencies helps make an application, such as an imaging library if your app deals with images or an Excel encoder if your app deals with Excel spreadsheets. Having the dependencies packed together for your app is just like how you packed your ingredients so that you can make your burger anywhere!
If we want to go a bit deep but not too deep, docker has a few extra concepts and is super easy to understand. There is a Dockerfile, a detailed recipe for your burger that states what exact ingredients you need in what quantities and where precisely in the burger you would place them. Would the tomato go on top of the onion or below? The Dockerfile helps Docker to set up your app in the way you want it to be 100% accurate every time. Similarly, there is a concept of a docker image, which means you have a ready-made version of your app to share with others but are frozen in time. In the burger example, let’s say you made those 10 burgers at home and froze them. This is called an image of your burger. At the picnic, you warmed them up and served without needing to put everything together on the spot. This would mean you created a running docker container off of the docker image you had, and you can do this as many times as you would like. Your friends loved the burger! It was quick and tasted the same. The last concept we will cover here is the Docker Hub, a place to share the docker images. In our burger example, this would mean something like you sold your burger images, Dockerfiles, or recipes to McDonald's so that you can get your burger around the world 24/7.
In summary, Docker lets us run our apps in dedicated containers where all dependencies are included beforehand. It also allows us to be more flexible in sharing or re-using our apps with Dockerfile, Images, and the Docker Hub.