What's the difference between Docker Compose and Kubernetes?

11/28/2017

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
docker
docker-compose
kubernetes

8 Answers

11/28/2017

Docker:

  • Docker is the container technology that allows you to containerize your applications.
  • Docker is the core of using other technologies.

Docker Compose

  • Docker Compose allows configuring and starting multiple Docker containers.
  • Docker Compose is mostly used as a helper when you want to start multiple Docker containers and don't want to start each one separately using docker run ....
  • Docker Compose is used for starting containers on the same host.
  • Docker Compose is used instead of all optional parameters when building and running a single docker container.

Docker Swarm

  • 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 ...
  • Docker Swarm is Docker in production. It is the native Docker orchestration tool that is embedded in the Docker Engine.
  • The Docker Swarm file named stack file is very similar to a Docker Compose file.

Kubernetes

  • Kubernetes is a container orchestration tool developed by Google.
  • Kubernetes' goal is very similar to that for Docker Swarm.

Docker Cloud

  • A paid enterprise docker service that allows you to build and run containers on cloud servers or local servers.
  • It provides a Web UI and a central control panel to run and manage containers while providing all the Docker features in a user-friendly web interface.

Update:

Docker cloud "partially" discontinued

The services on Docker Cloud that provide application, node, and swarm cluster management will be shutting down on May 21 [2020]... automated builds and registry storage services, will not be affected and will continue to be available

-- yamenk
Source: StackOverflow

6/7/2018

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 in 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

-- tgogos
Source: StackOverflow

8/6/2019

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

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

-- Aniket Alhat
Source: StackOverflow

11/28/2017

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
Source: StackOverflow

1/28/2020

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
Source: StackOverflow

3/21/2019

Docker Compose:

In a docker-compose.yml file each entry can optionally get docker-compose to build an image. each entry can represent a single container we want to build and each entry defines the networking requirements or ports.

Kubernetes:

Kubernetes expects all images to already be built and there is one config file per object we want to create and we have to manually setup up all networking.

So we ensure our image is hosted on Docker Hub, make one config file to create the container and one config file to set up networking.

-- Daniel
Source: StackOverflow

6/6/2019

Docker-Compose is a deployment file that predefined one or more container with its environment such as volumes, networking, a command to run and so on.

Kubernetes, on the other hand, is a system that orchestrates docker containers and other microservices by and makes them scaled and reliable across multiple nodes

-- Yaniv Hakim
Source: StackOverflow

1/23/2020

Docker compose: docker containers can be run directly with out assist of any yaml file. But with assist of Docker compose tool container properties can be defined inside a file called docker-compose.yml file. please find the below sample yml file for more details.

version: "3.7"
services:
  redis:
    image: redis:latest
    deploy:
      replicas: 1
    configs:
      - my_config
      - my_other_config
configs:
  my_config:
    file: ./my_config.txt
  my_other_config:
    external: true

name of image, number of replicas, etc.. can be configured through yml file.

Kubernetes: This is container management platform run on top of Docker built by google. Docker swam is another container management platform built by docker itself. Kubernetes also provide facility to save configuration related to pods(correspond to container in docker) in yaml file like docker compose. example yaml file

apiVersion: v1
kind: Pod
metadata:
  name: rss-site
  labels:
    app: web
spec:
  containers:
    - name: front-end
      image: nginx
      ports:
        - containerPort: 80
    - name: rss-reader
      image: nickchase/rss-php-nginx:v1
      ports:
        - containerPort: 88

here also images, ports to be opened and pod to host port mappings, etc.. can be given. like docker compose, kubectl apply -f is the command to run this file.

-- Nalin Kularathna
Source: StackOverflow