What's the difference between Docker Compose and Kubernetes?
- Containers are at the core of the other technologies listed here
- 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 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 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 (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
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 multipledocker ...
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/
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
If you are networking containers within the same host go for docker compose.
If you are networking containers across multiple hosts go for kubernetes.