68

Both Kubernetes Pods and the results of Docker Compose scripts (henceforth: "Compositions") appear to result in clusters of virtual computers.

The computers in the clusters can all be configured to talk to each other so you can write a single script that mirrors your entire end-to-end production config. A single script allows you to deploy that cluster on any container-host.

Given the similarities between the two systems, I'm struggling to understand what the differences are between the two.

Why would I choose one over the other? Are they mutually exclusive systems or can I run compositions in kubernetes.

Are there any critical considerations that need to be accounted for when designing for a container system? If I am designing the architecture for a site today and would like to try and build a container-based system. What are the highest priority things I should design for? (as compared to building on a single machine system)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Alex C
  • 16,624
  • 18
  • 66
  • 98

3 Answers3

56

docker compose is just a way to declare the container you have to start: it has no notion of node or cluster, unless it launches swarm master and swarm nodes, but that is docker swarm)
Update July 2016, 7 months later: docker 1.12 blurs the lines and includes a "swarm mode".

It is vastly different from kubernetes, a google tool to manage thousands of containers groups as Pod, over tens or hundreds of machines.

A Kubernetes Pod would be closer from a docker swarm:

Imagine individual Docker containers as packing boxes. The boxes that need to stay together because they need to go to the same location or have an affinity to each other are loaded into shipping containers.
In this analogy, the packing boxes are Docker containers, and the shipping containers are Kubernetes pods.

As commented below by ealeon:

I think pod is equivalent to compose except that kubernetes can orchestrated pods, whereas there is nothing orchestrating compose unless it is used with swarm like you've mentioned.

You can launch kubernetes commands with docker-compose by the way.

http://3.bp.blogspot.com/-MDUsXIy-lt0/VMuhJ9jBefI/AAAAAAAAA0I/qPuy0N8UXWA/s1600/Screen%2BShot%2B2015-01-30%2Bat%2B7.19.27%2BAM.png

In terms of how Kubernetes differs from other container management systems out there, such as Swarm, Kubernetes is the third iteration of cluster managers that Google has developed.

You can hear more about kubernetes in the episode #3 of Google Cloud Platform Podcast.

While it is true both can create a multi-container application, a Pod also serves as a unit of deployment and horizontal scaling/replication, which docker compose does not provide.
Plus, you don't create a pod directly, but use controllers (like replication controllers).

POD lives within a larger platform which offers Co-location (co-scheduling), fate sharing, coordinated replication, resource sharing, and dependency management.
Docker-compose lives... on its own, with its docker-compose.yml file

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Thanks Von. From the docker compose documentation https://docs.docker.com/compose/ this is a way to create multi-container applications, while a `dockerfile` is the equivalent of a single machine. So a POD ~= COMPOSE (I think) – Alex C Nov 26 '15 at 20:15
  • 1
    @AlexC True, but a Pod also serves as a unit of deployment and horizontal scaling/replication, which docker compose does not provide. Plus, you don't create pd directly, but use controllers (like replication controllers). POD lives within a larger platform which offers Co-location (co-scheduling), fate sharing, coordinated replication, resource sharing, and dependency management. Docker-compose lives... on its own, with its docker-compose.yml file. – VonC Nov 26 '15 at 20:22
  • ahhh... that makes sense. thanks! I think I get that now. – Alex C Nov 26 '15 at 20:37
  • 2
    i dont think this answer is correct. it looks like docker-compose.yml does have a concept of a node and cluster. https://github.com/docker/compose/blob/release/docs/compose-file.md i think pod is equivalent to compose except that kubernentes can orchestrated pods whereas there is nothing orchestrating compose unless it is used with swarm like you've mentioned – ealeon Jul 21 '16 at 15:10
  • 1
    Docker compose having a swarm-mode or not (cited above), this last comment makes a clear point about the main difference; should be pointed out clearly in the accepted answer – Ben Oct 02 '16 at 14:23
  • @ealeon I have included your comment in the answer for more visibility. – VonC Oct 02 '16 at 14:40
  • 1
    @Ben I agree. I have included ealoin's comment in the answer. – VonC Oct 02 '16 at 14:40
13

There's a difference with respect to networking:

The applications in a pod all use the same network namespace (same IP and port space), and can thus “find” each other and communicate using localhost. Because of this, applications in a pod must coordinate their usage of ports. Each pod has an IP address in a flat shared networking space that has full communication with other physical computers and pods across the network.

  • Containers in a docker-compose are assigned different IP addresses. See this blog post for more information.
Paulo Merson
  • 13,270
  • 8
  • 79
  • 72
10

Even though the above answer clearly answers this question, I'm adding some quick notes.

  1. Docker-Compose and Kubernetes pods both are configuration files (Yaml) that define container instances from images.

  2. Docker compose by itself is just a file that has the capacity to contain services (containers) for communication; it is inherently non distributed.

  3. Kubernetes pods also have the ability to define multiple containers, but the main difference here is the notion of distribution amongst available nodes.
  4. And lastly, Docker Compose is a tool for defining and running multi-container Docker applications without orchestration unless told to do so with Swarm. And a pod contains multiple containers that is shared in a cluster of nodes automatically if available.
Paulo Merson
  • 13,270
  • 8
  • 79
  • 72
Remario
  • 3,813
  • 2
  • 18
  • 25