Docker Compose vs Kubernetes

Docker Compose vs Kubernetes

What is Docker Compose?

Docker Compose
Docker Compose

You characterize a multi-container application in a single file, with Compose, at that point turn your application up in a single command which does everything that should be done to make it run.

Permits configuring and beginning numerous docker containers. This is generally utilized as an assistant when you need to begin different docker containers and would prefer not to begin every one independently utilizing docker run …. Docker compose is utilized for beginning containers on the same host.

What is Kubernetes?


Kubernetes is an open-source organization framework for Docker containers. It handles planning onto nodes in a compute cluster and effectively oversees outstanding burdens to guarantee that their state matches the client’s pronounced goals.

A container orchestration tool created by Google. Docker Kubernetes is for running and connecting containers on multiple hosts. Docker Kubernetes is a container cluster management and orchestration tool.

When contrasting Docker Compose versus Kubernetes, the Slant people group prescribes Kubernetes for a great many people. In the question “What are the best Docker coordination devices?” Kubernetes is positioned first while Docker Compose is positioned third. The most significant reason individuals picked Kubernetes is:

Kubernetes was based on quite a long while of experience from Google working on containers underway. It’s somewhat stubborn on how containers should function and act, however whenever utilized accurately it can enable you to accomplish deficiency tolerant systems.

What’s Kompose?

Kubernetes + Compose = Kompose

A conversion tool to go from Docker Compose to Kubernetes

Kompose is a transformation tool for Docker Compose to container orchestrators such as Kubernetes.

Why do developers like it?

  • Simplify your development process with Docker Compose and then set up your containers to a production cluster
  • Change your docker-compose.yamlwith one simple command kompose convert
  • Instantly bring up your cluster with kompose up
  • Bring it back down using kompose down


Migrating from Docker Compose to Kubernetes

For those individuals who have never used Docker Compose, it’s a framework that permits developers to define container-based applications in a single YAML file. Looking at the snippet below, each block of 5 to 20 lines represents a single service. Docker Compose is a very useful tool and makes application positioning fairly simple and easy.

Docker Compose to Kubernetes
Docker Compose to Kubernetes


Preparing for the Migration

The first difficulty to converting the project was learning how Kubernetes is changed from Docker Compose. One of the most intense ways it differs is in container-to-container communication.

In a Docker Compose situation, the containers all run on a single host machine. Docker Compose produces a local network that the containers are all part of. Take this snippet, for example:

Preparing for the Migration
Preparing for the Migration

This block will make a container called quoteServices with a hostname of quote-services and port 8080. With this definition, any container inside the local Docker Compose network can entrance it using http://quote-services:8080. Anything external of the local network would have to know the IP address of the container.

By contrast, Kubernetes usually runs on multiple servers called nodes, so it can’t simply generate a local network for all the containers. Before we started, I was very worried that this might lead to many code changes, but those worries would prove to be baseless.


Creating Kubernetes YAML Files

The best way to understand the conversion from Docker Compose to Kubernetes is to understand a real example of what the conversion looks like. Let’s takings the above snippet of quoteServices and convert it to a form that Kubernetes can recognize.

The first thing to know is that the above Docker Compose block will get converted into two isolated sections, a Deployment, and a Service.

As its name infers, the deployment states Kubernetes most of what it needs to know about how to deploy the containers. This information comprises things like what to name the containers, where to appeal the images from, how many containers to generate, etc. The deployment for quoteServices is shown below:

Creating Kubernetes YAML Files
Creating Kubernetes YAML Files

As we mentioned earlier, networking is done in a different way in Kubernetes than in Docker Compose. The Package is what enables the communication between containers. Here is the service definition for quoteServices next:

Creating Kubernetes YAML Files
Creating Kubernetes YAML Files

This service description tells Kubernetes to take the containers that have a name = quoteServices, as defined under selector, and to make them accessible using quote-services as hostname and port 8080. So again, this service can be reached at http://quote-services:8080 from inside the Kubernetes application. The elasticity to define services this way allows us to retain our URLs integral within our application, so no changes are required due to networking concerns.

At the end, we had taken a sole Docker Compose file with about 24 blocks and transformed it into about 20 different files, most of which confined a deployment and a service. This conversion was a big part of the immigration effort. Primarily, to “save” time, we used a tool called “kompose” to generate deployment and services files robotically. However, we ended up rephrasing all of the files nevertheless once we knew what we were doing. Using Kompose is sort of like using Word to generate webpages. Sure, it works, but you’re perhaps going to want to re-do most of it once you know what you’re undertaking because it adds a lot of additional tags that you don’t really want.


NCERT-NOTES Class 6 to 12.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Back to top button