Table of Contents Hide
Okay, so how many of these terms have you heard – Docker, Container, node, Pods, Services, Ingress, Etcd, Kubectl, configmap, secretmap, deployment, repository? Today is your lucky day because you are going to understand most of them.
This article is 2nd in our Kubernetes series and without understanding Dockers & Containers, we have no use of Kubernetes. As we discussed in introductory article, K8s are used for managing containers but the application runs inside containers. Let’s become the experts of Dockers.
Note: It’s completely fine If things seem confusing and not understandable. Docker & Kubernetes are complex because they don’t have a fixed starting and end point. By the end of this article, you will be able to join the dots.
Suppose you are a large enterprise. 100s of engineers are working on a software. Some of them are coders, some database experts and some manages the servers. These coders are separated in teams of their expertise languages like Java team, Php team, Python team, NodeJs team etc. Similarly, the DB experts are in MySql team, MongoDB team and Redis team.
Since the application is big, it is created using multiple languages and databases. Now I have few questions –
Q1. Have you ever worked in any such project where multiple languages like Java, Python, Golang etc. were used?
Q2. How can one language communicate with another in a single software?
Q3. How to build and package such software? Which compiler can do that?
Q4. How such software are hosted on servers?
Q5. How to scale them?
Q6. What if a machine fail and how to handle the situation?
So many questions, Right? Let me give you a hint – Dockers and Kubernetes. 😊
Because afterwards you can sleep like a baby. When you start developing an application the first thing you do is installing the required software. For a web application, you install Python or NodeJs, Mysql or MongoDb, Nginx or Apache etc. You then install all the dependencies required. There could be 20 or more. If there is another developer, they will install everything on their machine too. You must know how difficult it is to complete the whole installation without issues. Different OS and versions often breaks the functionality.
With Docker, you don’t install all these software or dependencies. You just install docker images which are consistent everywhere. So, all the developers will use the same command to install the images. No OS or version issues. Nothing.
Now you will ask, what is this “image”? We will see next.
Docker Image vs Containers
Docker Image is the set of instructions (also known as layers) and a bundle of all the pre-requisites of a particular software. Let’s understand this sentence –
Suppose you want to install MySql. For that you will search an executable on Mysql website and download the one appropriate for your operating system (Windows, Ubuntu, Mac etc.). Then you install it. Similarly, you do the same for Python or Php or Nodejs.
But these software are installed on your operating system. If you have windows then windows ones, if Ubuntu then linux ones etc.
On the other hand, Docker images runs on a predefined OS. Generally Ubuntu. So, if you need to install Mysql image, it may work like this –
- Install Ubuntu
- Update & Upgrade Ubuntu
- Install dependencies
- Install Mysql of latest version (or particular version if you specified while installing image)
- Fetch & install Mysql dependencies
Each of these steps are called layers. Layers are important because they are cached by Docker. So the next time you run a different version of Mysql image, it won’t run Ubuntu installation because it can pick from cache.
Now you can share this image to anybody and they don’t need to worry about anything. Just run the image and both of you will have the exact same environment of Mysql. No more hassles of installing things on your own. So Mysql image is a bundle of everything which Mysql requires in order to run on your system.
Container is nothing but the running image. As soon as you run an image, it becomes container.
We talked about docker images but from where do we get these images? Well there are multiple places. For example, there are repositories from Google, AWS, Azure etc. But the most famous is Docker Hub. Docker hub is the house of more than 100,000 images of different software, libraries, plugins and what not. You can find nearly everything as images.
This is not it. In fact, you can create your own images and upload on Docker hub for others to use. Suppose you are creating some application where you need Mysql, Python, MongoDb, Dot Net, and NodeJs. To create it, you will require docker images for all of them but you can create a single image of your application which will be the bundle of all the technologies we used. So now your other developer just need to install this image and she will be ready to work.
Next will learn how to install docker on Windows, MacOS and Linux. And we will create an application using multiple languages and databases so that you can understand the real power of Dockers and Kubernetes.
- Introduction to Kubernetes
- Introduction to Docker, Containers, Images & Repository
- Install and Run Docker Images
- Docker Image – FROM, RUN, COPY, ENTRYPOINT, CMD, EXPOSE explained
- Why docker run or start command not running my container?
- How to list all docker images in system?
- How to list all docker containers?
- How to start/stop a docker container?
- Difference between docker run and docker start
- How to bind docker container port with host?
- How to get logs of docker container?
- How to live stream logs of docker container?
- Set custom name to a docker container
- Access docker container filesystem & terminal
- Getting docker details using docker inspect
- Kyverno – Installation, Policies, Testing, Reporting, Monitoring, Security
- Complete Kubernetes Project Step By Step
- Introduction to Kubernetes Objects