448

While diving into Docker, Google Cloud and Kubernetes, and without clearly understanding all three of them yet, it seems to me these products are overlapping, yet they're not compatible.

For example, a docker-compose.yml file needs to be re-written so an app can be deployed to Kubernetes.

Could someone provide a high-level, rough description of where Docker, Docker Compose, Docker Cloud, and Kubernetes overlap and where one is dependent on the other?

George Katsanos
  • 13,524
  • 16
  • 62
  • 98

5 Answers5

831

Containers:

  • Containers are at the core of the other technologies listed here

Docker:

  • Docker is a popular implementation of the technology that allows applications to be bundled into a container.
  • docker is a command-line tool to manage images, containers, volumes, and networks

Docker Compose

  • Docker Compose is the declarative version of the docker cli
  • It can start one or more containers
  • It can create one or more networks and attach containers to them
  • It can create one or more volumes and configure containers to mount them
  • All of this is for use on a single host

Docker Classic Swarm

  • Docker swarm has been abandoned by Docker Inc. and is not being actively maintained or supported.
  • Docker Swarm is for running and connecting containers on multiple hosts.
  • Docker Swarm is a container cluster management and orchestration tool.
  • It manages containers running on multiple hosts and does things like scaling, starting a new container when one crashes, networking containers ...
  • The Docker Swarm file named stack file is very similar to a Docker Compose file
  • The only comparison between Kubernetes and Compose is at the most trivial and unimportant level: they both run containers, but this says nothing to help one understand what the two tools are and where they are useful. They are both useful for different things

Kubernetes

  • Kubernetes (K8S) is a distributed container orchestration tool initially created by Google
  • It was open-sourced in 2014 and handed over to the Cloud Native Computing Foundation (CNCF) the following year
  • The CNCF is an industry body with hundreds of members drawn from the majority of large cloud, software and hardware companies
  • At the time of writing (late 2021) there are nearly a thousand K8S related projects split into around twenty classes with a total of over $21 billion dollars in funding
  • Kubernetes (2021) is the most popular distributed system orchestrator in the world with 88% adoption
  • Because of its near ubiquity, K8S has become the most popular contemporary platform for innovative system development in 2021
  • Kubernetes is a competitor (more or less) to Docker swarm but does more stuff than docker swarm i.e a popular choice.
Umar Hayat
  • 4,300
  • 1
  • 12
  • 27
yamenk
  • 46,736
  • 10
  • 93
  • 87
  • All good, about the last thing "Docker cloud, allows you to run containers.." practically, what can you do with running these containers on the cloud? can they provide publicly accessed endpoints? essentially is a docker cloud something like AWS but for docker containers? (or is it just a container library for discovery) – George Katsanos Nov 28 '17 at 21:29
  • 10
    Ok Sorry. I think I'm still confused. So does that mean docker-compose is like Kubernetes in that it is used to orchestrate containers locally and is more of convenience for local development or is Kubernetes much more than this? – Vipin Menon Feb 16 '18 at 05:33
  • 2
    @VipinMenon Kubernetes is a competitor (more or less) to Docker Swarm. Its for multiple machines (and is more complicated/does more stuff than even docker swarm does, at least from what I've seen). So yes, much more than just local container management. – mbrig Jun 20 '18 at 03:23
  • 27
    Is it fair to make the following analogy 1. docker-compose <> minikube 2. docker-swarm <> kubernetes cluster 3. docker-cloud <> managed kubernetes cluster by GCP, AWS, etc – Anoop May 22 '19 at 22:35
  • 2
    "Docker swarm is for running and CONNECTING containers on multiple hosts." : What does "connecting" means here? Network connection? – someone_ smiley Dec 04 '19 at 04:33
  • 3
    @someone_smiley Yes. It creates an _overlay network_ – OneCricketeer Mar 25 '20 at 22:22
  • Is there really a separate stack file? I'm under the impression that [Swarm uses Docker Compose files](https://technologyconversations.com/2017/01/23/using-docker-stack-and-compose-yaml-files-to-deploy-swarm-services/). – Matthias Braun May 29 '20 at 20:29
  • i believe minikube is just a mini kubernetes(1 node) setup for local development. – Isaac Pak Oct 12 '20 at 21:17
  • Can somebody who is more familiar with docker swarm update this post? [Docker's official docs](https://docs.docker.com/engine/swarm/) now say "Do not confuse Docker Swarm mode with Docker Classic Swarm which is no longer actively developed." – jrh Nov 10 '21 at 17:52
230

In addition to @yamenk's answer, I'd like to add a few details here which might help people with their journey of understanding Kubernetes.

Short answer:

  • docker-compose: is a tool that takes a YAML file which describes your multi-container application and helps you create, start/stop, remove all those containers without having to type multiple docker ... commands for each container.
  • Kubernetes: is a platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. What? Keep reading...

Docker Compose

(from the docs): 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. Compose has commands for managing the whole lifecycle of your application:

  • Start, stop, and rebuild services
  • View the status of running services
  • Stream the log output of running services
  • Run a one-off command on a service

Kubernetes

(from Introduction to Kubernetes): Kubernetes is a container orchestrator like Docker Swarm, Mesos Marathon, Amazon ECS, Hashicorp Nomad. Container orchestrators are the tools which group hosts together to form a cluster, and help us make sure applications:

  • are fault-tolerant,
  • can scale, and do this on-demand
  • use resources optimally
  • can discover other applications automatically, and communicate with each other
  • are accessible from the external world
  • can update/rollback without any downtime.

Many people argue that Kubernetes is hard to learn. It's because it solves a series of problems and people try to understand without knowing all the prerequisites. This makes it complicated. Start putting the pieces of the puzzle together by reading about concepts/terms like the following. This process will help you understand the kind of problems Kubernetes tries to solve:

  • 12-factor apps,
  • Automatic binpacking,
  • Self-healing mechanisms,
  • Horizontal scaling,
  • Service discovery and Load balancing,
  • Automated rollouts and rollbacks,
  • Blue-Green deployments / Canary deployments
  • Secrets and configuration management,
  • Storage orchestration

And because there are a lot of different things around containers and their management, keep an eye on the Cloud Native landscape:

Interactive version here: landscape.cncf.io/

enter image description here

Updates

May 2020: Docker Compose Specification is now an open standard

Working with AWS, Microsoft, and others in the open source community, we have extended the Compose Specification to support cloud-native platforms like Kubernetes, and Amazon ECS in addition to the existing Compose platforms. More here: blog / compose-spec.io

Pang
  • 9,564
  • 146
  • 81
  • 122
tgogos
  • 23,218
  • 20
  • 96
  • 128
  • 3
    This answer is outdated. https://www.docker.com/blog/simplifying-kubernetes-with-docker-compose-and-friends/ – OneCricketeer Mar 25 '20 at 22:26
  • 2
    Thanks @cricket_007 I'll keep an eye on this, but I think this blog post from 2018 is kind of... "marketing". It's 2020 and if you check the docs at [Docker Compose](https://docs.docker.com/compose/) and [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/) there is nothing about Kubernetes. – tgogos Mar 26 '20 at 13:45
  • 1
    So? https://github.com/docker/compose-on-kubernetes `docker stack deploy --orchestrator=kubernetes` ... https://docs.docker.com/engine/reference/commandline/stack_deploy/ – OneCricketeer Mar 27 '20 at 19:48
  • 2
    oh, amazing that there's a compose layer that abstracts all the kubernetes syntax! Thanks @cricket_007 . – George Katsanos Apr 25 '20 at 18:08
  • 3
    Personally I find it overwhelming when someone asks a basic question about a technology like kubernetes and the first thing someone does is throw the CNCF landscape at them thinking the thumbnails of 500 apps they've never heard of will make anything more clear. – Ryan McGrath Nov 23 '21 at 05:20
156

If you are networking containers within the same host go for docker compose.

If you are networking containers across multiple hosts go for kubernetes.

Kita
  • 2,604
  • 19
  • 25
Aniket Alhat
  • 677
  • 1
  • 5
  • 5
  • 27
    That's the type of answer I was expecting! Even though it could have some more explanation, "tl;dr" part is really the point. None of other answers actually says that! – The Godfather Feb 15 '20 at 14:40
  • There are many concepts of binding a container(multi-container pod strategy like a sidecar, ambassador or adaptor) or pod(node selector, node name, pod affinity, etc) together in Kubernetes as well. I am not pretty convinced with the above answer, until and unless I'm missing something. – Abhishek Jul 23 '20 at 08:38
  • @Abihishek, I upvote you. so do you mean ` a node in Kubernetes` = `a host(cloud server or pc or laptop)` ? – Denis Turgenev Jun 26 '21 at 15:33
  • Definitely you do not want to go with Kubernetes only for managing multiple host. There are lots of other things those are provided by Kubernetes. – Saiful Islam Jul 28 '22 at 07:47
  • Also nice comparison is [here](https://www.baeldung.com/ops/docker-compose-vs-kubernetes) – Eugen Konkov Oct 27 '22 at 11:17
16

first distinction is between the container engine and the container orchestrator.

docker is a container engine, it makes you build and run usually no more than one container at most, locally on your PC for development purposes.

docker-compose is a Docker utility to run multiple containers and let them share volumes and networking via the docker engine features, runs locally to emulate service composition and remotely on clusters.

Kubernetes is a container orchestration platform, it takes care of running containers and enhancing the engine features so that containers can be composed and scaled to serve complex applications (sort of PaaS, managed by you or cloud provider). Main Kubernetes feature is to decouple infrastructure from application using containers, and it's also open for other engines that Docker, for example it can run containers with rkt or cri-o.

Docker cloud is also a PaaS offer that will let you run and orchestrate containers through the docker engine API.

Now depending on your needs, level of control on infrastructure and target audience you can use either Kubernetes on baremetal, or Azure ACS or Google GKE, etc...

Hope this helped :) Regards

Francesco Gualazzi
  • 919
  • 1
  • 10
  • 23
  • 2
    I'm a bit confused why do you usually only run one container on docker? While I think Docker-compose is a better solution, there is nothing stopping you from starting multiple containers without it! – Peter Sep 23 '18 at 13:10
  • 2
    oh yes, sometimes I have a mysql running in background then starting httpd and nginx as standalone containers... but then when I want the whole thing automated I'll definitely build a docker-compose.yml to specify dependencies, networks, etc... – Francesco Gualazzi Sep 24 '18 at 06:52
7

Docker Compose is not a production ready tool. It works great for PoC or development environments, but lacks a lot of the capabilities that are more or less table stakes for serious production use. Swarm is more production-ready, but I would never invest into Swarm in a greenfield scenario. Kubernetes has won the orchestration battle, as evidenced by its inclusion into Docker Desktop and it being offered by all major cloud providers. Kubernetes is much more capable and has far more community and corporate support.

I would recommend diving into some of the Kubernetes tutorials available at Pluralsight, Linux Academy, etc. and spinning up a cluster to play around with in your cloud platform of choice (EKS, AKS, GKE, etc.). If you are trying to spin up on bare metal, take a look at OpenShift, but recognize that you lose some of the magic of Kubernetes in this setup.

Ashok Reddy
  • 1,060
  • 1
  • 16
  • 28
  • Agreed that k8s has "won" (for now). But Mesos used to be referred to as the [gold standard for production clusters](https://d2iq.com/blog/docker-vs-kubernetes-vs-apache-mesos). DC/OS did a fine job of pushing the enterprise features out, but now you can even run multiple k8s clusters within a Mesos environment and access them from a single vendor-agnostic platform so which is really better? – OneCricketeer Mar 25 '20 at 22:24
  • A quick note from the future: 2021 here, and K8S hasn't won 'for now' it has simply won. K8S is the only show in town and will soon be as ubiquitous as VMs. Swarm is dead, abandoned by its owner. Docker-compose is still used, by developers on their desktops and for small prototypes, but really the answers here are all wrong and compose is not about orchestration at all so shouldn't be compared to K8S. – Software Engineer Aug 09 '21 at 12:00