Journey from Docker Compose to Kubernetes

If you worked with Docker Compose in the past, then you know it’s a great tool. It provides all kinds of functionality, from building images to running containers to looking at logs and more.

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. — Docker Documentation.

Mapping Docker Compose to Kubernetes

An example of docker compose in perspective of Kubernetes

Now we can do this translation manually one by one by remembering all syntax and parameters, Or choose following 3 ways to create K8s services:

1. Kubernetes using Docker Stack

To enable Docker Stacks Command to Kubernetes

Normally you have to do a swarm initializer phase, run a command and get your Docker swarm configured and enabled. But by checking this check box, you can override that default behavior and make it so it runs these up in kubernetes.

2. Kubernetes using Kompose

Kompose is a tool to help users familiar with docker-compose move to Kubernetes. It takes a Docker Compose file and translates it into Kubernetes resources.

To install kompose, follow instruction on : https://kompose.io/installation/

To convert the docker files to kubernetes yaml, use following command in de docker-compose directory with options:

$ kompose convert --file docker-compose.yaml --out ./k8s

This command will convert docker services to kubernetes services and deployments in k8s folder.

3. Kubernetes using Skaffold

To install kompose, follow instruction on : https://skaffold.dev/docs/install/

Generating a skaffold.yaml : skaffold init can be used to generate the initial configuration to deploy a project to kubernetes.

$ skaffold init --compose-file docker-compose.yml

Once skaffold.yml is generated, skaffold dev can be to watches code for changes and build and deploys it automatically to kubernetes cluster.

An Azurer, Web developer, Technologist, Writer, Poet, Runner. Opinions are my own.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store