CoDeKu DevOps Academy Blog - DevOps & Cloud Blogging Platform

Table of Content
Story of the Magical Restaurant 🍽️
There was a magical restaurant in a busy city called Cloudvillage. The importance of this restaurant was, its kitchen is powered by a magical tool called docker. Chef Ramitha is the one who was the master chef of this kitchen.
He had a special recipe book 📖 that described exactly how to make a dish. Additionally, this book describes what ingredients to use, how to cook it, what temperature, which spices, and even what plate to serve it on for each dish. We can identify this book called Docker Image. It’s a read-only blueprint or template that contains the app, libraries, configurations, and everything needed to run something.
When a customer came into the restaurant and he ordered a dish, the chef copied the recipe, used the magical tools, and instantly made it. Each dish was served on its own plate. These dishes are Docker Containers. These can be pointed out as the running instances created from Docker Images.
Here, Chef Ramitha has different benefits. Let’s consider what they are. Let’s imagine, a customer orders a spaghetti dish.
- The chef can make five spaghetti dishes if he need. 🍝🍝🍝🍝🍝
- Customize one dish without affecting the others. (add mushrooms 🍄)
- Trash a dish if it goes bad without touching the recipe or other dishes. 🗑️
Bring the story to the Programming World🔄

So Docker lets developers like us, to write a code once and define everything needed in a Docker image. And we can run that image and create a container using that image just like Chef Ramitha serving perfect dishes every time. 👨💻🍽️
Recipe Book / Docker Hub📖

This is a screenshot of the Docker Hub. We can consider this as the recipe book that provides the details of how to make various dishes. Here A section can be considered as the categories section of the recipe book. And the B part can be considered as the dishes section. We can point out these TensorFlow, PyTorch, and nginx as the dishes.
Let’s cook a dish called Nginx 🍕

This can be pointed out as a recipe of a specific called Nginx. This page describes how to make this dish with all the details such as how to cook it, what temperature, and which spices etc. 👨🍳 We can make a copy of this recipe to my workplace using the docker pull nginx.

This is the way how to make a copy of the nginx recipe in our workplace. We can check what are the recipes or images in our workplace using docker images. After copying, we can make the dish, using that recipe. We can call this as making a container using the image as well.

We can create our Nginx dish using the Nginx recipe like this. After making the dish, an ID is generated. We can use this ID to identify our dishes from other dishes. Also, we can check what are the created dishes using the docker container ls command. We can also use the docker ps command for this process. Then we can see some details like the dish’s ID, the recipe, when we created it etc.
Let’s add some mushrooms 🍄

If we need to trash a dish we can use this docker stop (container ID) command. We can change the port of this 80/tcp to our machine’s port like 9090. Actually, this 80/tcp port is a container’s port. Not our machine’s port. So we cannot deal with that. So we have to replace that with our machine’s port. This process can be identified as ‘customizing the dish as our wish’ or Exposing a port.

We can customize the port using this way. Here we can see the port is changed to 9090. Now we can check whether this works fine using our web browser. Open your web browser and navigate to the localhost:9090. Then you will see the below type of screen.
