Top 5 reasons to migrate from docker-compose to Kubernetes

2 years ago   •   6 min read

By Ajay Kumar Yadav, Abhinav Dubey,

Table of contents

What is docker compose ?

It is a  command line utility that helps to define and share multi-container applications, create a yaml file to define the services with a single command and can spin up everything  at once.

Note: First we  will deploy an application with the help of docker compose and then we will migrate the same on K8s.

In this blog we will walk through the steps to migrate docker compose set up over Kubernetes just in minutes and all thanks to Devtron.

Overview of our Application

We have a simple flask application which is going to connect with the redis application. and create a route in flask which is going to return the total number of hits the website has. We are using in-memory database i.e redis for the same.

Feel free to explore the Github repository for more details.

Deploying application using docker compose.

Here we have installed docker and docker-compose utilities in AWS EC2 instance and deployed an application over there using docker-compose.

spin up docker compose setup

Now take the public IP of instance and port number so that we can access the application using its public IP


After that when we will hit again this count going to increase

Here we have successfully set up applications using docker compose .

Disadvantages of Docker Compose

  • Docker's compose server might have a single point of failure.
  • Have to start from scratch when it comes to high availability.
  • You don’t have health checks available in production with Docker Compose. Unfortunately, docker run and docker-compose won’t re-create containers that failed a built-in health check.
  • You can’t replace a container without downtime. No rolling updates are available.
  • Docker Compose fails to prove itself on reboots. In fact, it is only a wrapper around the Docker API. This means that you can not count on it running as a separate process. This way, all the yaml changes (including containers) are erased from Docker’s memory once it restarts.

Why Move to Kubernetes?

  • Docker Compose has some advantages over Kubernetes⁠⁠⁠ perhaps especially for those still new to containerization; the learning curve isn’t as steep with the former as it is with the latter.
  • Docker Compose has limitations that make Kubernetes more appealing as an option. For starters, Docker Compose is designed to run on a single host or cluster, while Kubernetes is more agile in incorporating multiple cloud environments and clusters.
  • Kubernetes is easier to scale beyond a certain point plus you can utilize native services of AWS , Azure and GCP to support our deployment.
  • Resource optimization and features like self healing is natively supported by Kubernetes but we don't see such features with docker-compose.
  • Last but not the least, k8s ensures to provide nearest 0 downtime of your applications while migration, or maybe new releases by using different deployment startegies like `Canary Deployments` but in case of docker -compose these strategies are not possible.

It is clear though that the biggest reason to move to Kubernetes is flexibility. When you have reached a certain point with Docker Compose, moving to Kubernetes as your container runtime is the logical step to take. You can take your application to the next level with the migration.

Here we are going to use the intuitive UI of Devtron to migrate the above setup.

Prerequisites to migrate into K8s

  • Must have a k8s cluster - In our case, we have an EKS cluster.
  • Devtron installed in cluster - Feel free checkout its well managed documentation for installing Devtron

Note: setup the Global Configuration of Devtron after its installation.

Latest code of the flask application is in the main branch of the repository.

Here we are deploying the redis application using the helm chart.

Click on the Charts store (from the left menu of the dashboard) and search for redis. You will see a lot of charts present there from different chart repositories. Then click on deploy as seen below, it will open the chart configs where we have to fill details like - App Name, Project, Environment and the version of chart you want to deploy. After giving the details, and configuring values as per your requirements, click on Update and Deploy

All redis k8s objects created successfully here.

redis app details

Now let’s deploy the flask application.

Click on Create New >> Click on Custom App

Give the details of application

From here we can give the App Name, Project and select the Template. Selecting a template allows us to copy the same configurations of an existing app but in our case we will create it from scratch.

flask app information

Configure Git Repository

In Git Repository, select the Git Account (It is public by default or for private repos, select the account added) and provide the git repo url of your application which needs to be deployed

Configure Docker Build Config
In Docker Build Config select the container registry from drop down, provide the repository name and give a path to the Dockerfile of your application.

Configure Deployment Template
Devtron provides a pre-installed deployment template consisting of all the important configuration required to deploy an application. Just change the configs as per your requirements and save the deployment template as shown in below.

Note:- Here we have created the ingress for flask application, will access through it.

Configure workflow

Now after saving the deployment template, we need to create a CI-CD workflow. Devtron provides an awesome feature to configure the CI pipeline & CD pipeline of our applications which makes our life easy.


Configure Config Map
Now we need to create ConfigMap with the  following environment variables for our application so that it can communicate with a redis application.


After all the Application configurations are done, we need to trigger our CI pipeline which would build an image and then trigger the CD pipeline, which would deploy the application. Navigate to the Build & Deploy tab >> click on Select Material and select the commit for which you want to create an image. Once the CI part is done, click on Select Image and select the image you want to deploy.

Now navigate to the App Details tab and you can see the status as Healthy and all the k8s workload in the dashboard.

When we hit the ingress hostname with /flask path, will see below

After refresh it will increase the hit count.

Hurray! Finally We have migrated the docker compose application setup into k8s through Devtron. Hope you get a better understanding on how to migrate, manage applications as well as helm charts through Devtron and how easy it is. If you have any doubts, feel free to let us know through comments and join our discord community to get the latest updates about Devtron.

Spread the word

Keep reading