1

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"
X0r0N
  • 245
  • 1
  • 3
  • 7

1 Answers1

1

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.

kubanczyk
  • 13,812
  • 5
  • 41
  • 55