From what I read it seems that Docker-Compose is a tool to create multiple containers on a single host while Docker Swarm is a tool that can do the exact same thing but with more control and on multiple hosts with the help of Docker Stack. I went through the tutorial and also came across this thread:
docker-compose.yml vs docker-stack.yml what difference?
And I'm coming to the conclusion that there's no reason to ever use Docker-Compose when you can use Docker Swarm with Docker Stack. They can even use the same docker-compose.yml.
It seems that Docker-compose came before the swarm and stack and maybe the new solution of swarm + stack makes compose obsolete, but it still remains for legacy reasons. Is this thinking correct? If not, what benefits does Docker-Compose have over Docker Swarm and Docker Stack in terms of making a development or production environment?
From what I have found: What's the difference between Docker Swarm, Docker Compose and Docker Networks?
Docker Compose is a client side tool that allows you to run an application stack with multiple components.
Docker Swarm is a server side feature that enables you to:
A swarm is a cluster of docker nodes (machines) that act as underlying resources for starting multiple container. One can orchestrate and deploy services across the swarm.
Allow containers across all nodes to communicate with one another
View official documentation at: Swarm mode overview & Docker Compose
In short, yes. Compose came before all the Swarm stuff (it originated as a 3rd party utility called
fig
). To make matters worse, there are even two different Swarms, old Swarm (the one that was a separate tool) and Swarm Mode (which is built into thedocker
binary these days).It seems to be evolving into services and deployment concepts that get built into Docker. But I would guess Docker Compose and the Swarm Mode deployment stuff will live side by side for a while.
It is also beneficial to know that Docker Compose underpinnings live as a library called
libcompose
(https://github.com/docker/libcompose) which other 3rd party utilities make use of to support thedocker-compose.yml
file format for deploying (see Rancher andrancher-compose
as an example). I would imagine they would make an effort to continue support forlibcompose
.I am unclear if the Docker Swarm deployment stuff actually uses
libcompose
. In my cursory searches, it would appear that Swarm Mode does not implementlibcompose
and does its own thing. I am not sure how this relates to the future of Docker Compose andlibcompose
. Interpret as you see fit...