21

I am new docker-user. And in difference manuals I have find usually docker-compose.yml file for description docker job, but on docker site for this goal used docker-stack.yml file. What difference?

Oleksii Sytar
  • 353
  • 5
  • 17

3 Answers3

16

docker-compose.yml is for the docker-compose tool which is for multi container docker applications on a single docker engine.

its called with

docker-compose up

docker-stack.yml is for the docker swarm tool. (for orchestration and scheduling).

its called with

docker stack
Gabbax0r
  • 1,696
  • 3
  • 18
  • 31
  • 1
    Okay, for what (practical)goal better use docker swarm tool, and can i compare them? – Oleksii Sytar Apr 06 '17 at 10:07
  • The official docker introduction uses docker-compose.yml with `docker stack` so I guess it's just a naming convention. – davidA May 29 '17 at 03:31
  • @meowsqueak the offical docker-compose docs uses docker-compose. as you can see here https://docs.docker.com/compose/overview/ the 3 point on the top of the sheet. 1. make Dockerfile, 2. make docker-compose.yml, 3. docker-compose up – Gabbax0r May 29 '17 at 05:37
  • 3
    @Gabbax0r sure, that's the docker-compose docs though, not the docker docs. I was referring to the Get Started "introduction" for *Docker* which makes use of docker-compose.yml with `docker stack` but never mentions the `docker-compose` tool itself. A minor documentation inconsistency perhaps. https://docs.docker.com/get-started/ – davidA May 29 '17 at 22:09
8

To add to Gabbax0r reply:

Docker Swarm was a standalone component used to cluster Docker engines as a single one.

As of Docker 1.12 the "Swarm" standalone was integrated inside the Docker engine (read the preamble at this page), and Swarm is (or will be) legacy.

To reply to your original question, it is just different names for different cases, but they both are meant to serve the same purpose.

To reply to your comment question, use docker-compose when you have to orchestrate a multi-container app on a single node; if you have to worry about multi-nodes and load-balancing and all this advanced stuff, you better off go with the Swarm.

linuxbandit
  • 2,362
  • 1
  • 14
  • 13
  • Why not use Swarm on a single node too – KajMagnus Sep 01 '17 at 04:59
  • @KajMagnus You could, but what is that you are trying to achieve then? – linuxbandit Sep 17 '17 at 12:13
  • 2
    Linuxbnndit: then, when you learn Swarm for a single node, you'll learn Swarm syntax and terminology, rather than Docker-Compose. Later, if you want to scale to many nodes, you'll be familiar with Swarm already, and all tools you might have built, will use Swarm commands already. So you'd save some time. ... I actually posted a question: https://stackoverflow.com/questions/45993496/any-reasons-to-not-use-docker-swarm-instead-of-docker-compose-on-a-single-nodev – KajMagnus Sep 17 '17 at 18:12
0

The docker-stack.yml has the advantage over docker-compose.yml :

  1. Update separately

    When working with services, swarms, and docker-stack.yml files, keep in mind that the tasks (containers) backing a service can be deployed on any node in a swarm.

    This may be applied to a different node each time the service is updated.

  2. Deploy remotely

    If you are running Docker Swarm on your private host then docker-stack.yml can use to access and deploy your application remotely to the host using an SSH key.

    You may even use such a service like Codefresh to do so.

eQ19
  • 9,880
  • 3
  • 65
  • 77