i am trying to deploy a stack to my docker swarm but it does not work. i call the command

sudo docker stack deploy -c docker-compose.yml server-test

but it gives me the error

unsupported Compose file version: 2

but when i run docker-compose up, it works fine. i then check the docker-compose --version which gives me:

docker-compose version 1.21.2, build a133471

this is the latest version as of writing this. i'm fairly new to docker so any guidance on this is appreciated.

my docker-compose.yml file is as follows:

version: '2'

    build: .
      - "80:80"
      - "443:443"
    image: portainer/portainer:latest
      - "9000:9000"
      - "/var/run/docker.sock:/var/run/docker.sock"

The error refers to version: '2' in the first line of docker-compose.yml. You need to change syntax to at least version: '3.0' then docker stack will work.

There is upgrade guide for docker-compose.yml.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.