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.

  • crontab not working ubuntu 16.04
  • How to use docker for many connected projects
  • Accessing Docker-compose containers hostnames from a container
  • Kubernetes installation on centos7
  • Install Docker using a Dockerfile
  • Unable to launch tomcat using docker
  • 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?

  • Providing a stable url to access a docker container from another docker container
  • Docker: docker-compose.yml file of nginx+mariadb+php+redis
  • Docker not restarting and building
  • how to enable docker remote api on windows-10
  • Mounting local directory into Docker container path that is not exposed as a VOLUME
  • building in docker using buildpack-deps, but dependencies don't seem to be installed?
  • 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.