What's the difference between a stack file and a Compose file?

I’m learning about using Docker Compose to deploy applications in multiple containers, across multiple hosts. And I have come across two configuration files – stack file, and Compose file.

From the Cloud stack file YAML reference, it states a stack file is a file in YAML format that defines one or more services, similar to a docker-compose.yml file but with a few extensions.

  • Docker pass containerID to the application running inside container itself
  • Docker Toolbox Mac command line and Kitematics fails
  • How to debug Golang application in Docker with VSCode?
  • Docker local repository deletion does not free space
  • Bluemix Unable to connect or ping to container
  • RabbitMQ on Docker: Pika hangs on connection when given port, connection refused without port
  • And from this post, it states that stacks are very similar to docker-compose except they define services while docker-compose defines containers.

    They look very similar, so I am wondering when I would use the stack file, and when to use the Compose file?

  • Docker Ubuntu Behind Proxy
  • XRDP in Docker Container KDE segfault, LXDE OK
  • Docker forking process
  • How to start a docker container when windows boots
  • How to properly give argument to docker entrypoint when building a container (docker run …)?
  • Browsersync within a Docker container
  • One Solution collect form web for “What's the difference between a stack file and a Compose file?”

    Conceptually, both files serve the same purpose – deployment and configuration of your containers on docker engines.

    Docker-compose tool was created first and its purpose is “for defining and running multi-container Docker applications” on a single docker engine. (see docker compose overview )

    You use

    docker-compose up 
    

    to create/update your containers, networks, volumes and so on.

    Where Docker Stack is used in Docker Swarm (Docker’s orchestration and scheduling tool) and, therefore, it has additional configuration parameters (i.e. replicas, deploy, roles) that are not needed on a single docker engine.

    The stack file is interpreted by

    docker stack  
    

    command. This command can be invoked from a docker swarm manager only.

    You can convert docker-compose.yml to docker-cloud.yml and back. However, as stated in your question, you must pay attention to the differences. Also, you need to keep in mind that there’re different versions for docker-compose. Presently, the latest version is version 3. (https://docs.docker.com/compose/compose-file/)

    Edit: An interesting blog, that might help to understand the differences, can be found here https://blog.nimbleci.com/2016/09/14/docker-stacks-and-why-we-need-them/

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.