I just heard of the native Kubernetes support in the future Docker version. I never used Kubernetes before, so I started reading about it. But I got a little bit confused: Kubernetes is described as orchestration tool and also as an alternative to Dockers swarm mode.
So if Kubernetes does orchestration, is it also an alternative to docker-compose? Or can compose and Kubernetes be used together?
Some specific questions: Let's say I want (or have) to use Kubernetes:
What is the difference between these three? I can sum it up in a single sentence: Docker (or specifically, the docker command) is used to manage individual containers, docker-compose is used to manage multi-container applications and Kubernetes is a container orchestration tool. Of course, nothing is quite that simple.
The difference between Docker Swarm and Docker Compose is that Compose is used for configuring multiple containers in the same host. Docker Swarm is different in that it is a container orchestration tool. This means that Docker Swarm lets you connect containers to multiple hosts similar to Kubernetes.
Kompose supports conversion of V1, V2, and V3 Docker Compose files into Kubernetes and OpenShift objects.
Yes you could use them together. When you add a node to the cluster, the node's workloads are managed by a default orchestrator, either Docker Swarm or Kubernetes. You can use Docker EE 2.0 to install Kubernetes and Swarm components across every node in a cluster.
First of all, Kubernetes and Docker's Swarm "mode" are both container orchestration tools. Docker compose
, the tool and the YAML file format, has historically been the way to describe multi-container applications that are then deployed into Docker's Swarm mode orchestrator.
Kubernetes has its own YAML service definition (and other definition file formats) which are not using the compose file format.
However, with the announcement of Docker's Kubernetes support, they will be providing the capability for the Docker compose
tool to also target taking a compose YAML file and deploying the "content" of that compose file (networks, services + env/secrets) into a Kubernetes cluster, with Kubernetes orchestration engine placing those components on K8s pods.
Based on the above statements, your questions are really about whether you would want to switch to defining your services, environment, networks, etc. in Kubernetes YAML, or would you rely on Docker's support to use the compose format and target either Swarm mode or K8s. That is more of a business decision between Docker's support for Kubernetes or open source or other commercial Kubernetes options, so there are not necessarily direct (and/or exactly correct) answers to your questions.
So if Kubernetes does orchestration, is it also an alternative to docker-compose?
Short Answer: NO
It's not just orchestration, essentially Kubernetes
is a production grade container orchestration and scheduling engine. It is far more advanced than docker-compose
itself. I would say docker swarm
, kubernetes
and amazon ecs
belong in the same category.
Or can compose and Kubernetes be used together?
In the next version of docker engine you will be able to use docker-compose to create kubernetes
objects. But as of now you can't.
I have a docker-compose file containing multiple microservices, but they are running as a standalone app on a single machine. Can (or should) it be replaced by Kubernetes?
Ok, in the context of running it in production, I would say absolutely, you should definitely look to host your applications on a kubernetes
cluster because it provides
and many more features out of the box. And when you declare a state kubernetes
would always try to achieve and maintain that state.
I have a docker-compose file with multiple services configured in swarm mode (running on multiple machines). Which part has to be replaced by Kubernetes? The whole compose file? Or is it somehow possible to define basic configuration (env_var, volumes, command, ...) within compose file and use Kubernetes only to orchestrate the clustering?
I would replace the whole swarm cluster and compose files constructs with a kubernetes
cluster and object definition yaml
s. Having said that from my experience those yamls
can get bit verbose so, if you are keen have a look at Helm. It is a package manager for kubernetes
which, you don't have to use but I think it is one of the best tools in kubernetes
ecosystem at the moment and there are plenty of open source charts readily available.
I would heavily recommend playing around with kubernetes
using minikube
on your local system just to get familiar with the general concepts. And then you will be able to answer the above questions for yourselves.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With