Docker Stack Deploy Does Not Work

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'

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

change the version to ‘3’

1 Like

@xoron what version of Docker are you using? You should always check docker engine + docker compose version to understand the compose file version supported.

Take a look at the release notes for your docker-compose binary and the documentation to better understand the versioning model.

thanks. this worked!