0

I am trying to deploy my docker stack using compose file. When I deploy with compose file version 3+, the deploy works perfectly fine. But when I am trying to use the 2.4 version or lower I get this error: unsupported Compose file version: 2.4

I need to use the 2.4 version, because Version 3 and higher does not support several parameters I need for my containers (such as cpuset and runtime).

My version of docker is 19.03.6 and docker-compose is 1.25.4.

Is there any way to deploy with an older version of compose file on Docker 19.03.6? Am I missing something or is the latest docker version does not support the older compose files anymore?

UPDATE

It turns out that docker 19.03.6 supports only Version 3+ in deploy. So I can't use anything but Version 3+, which does not provide the same flexibility as V2.4 in terms of CPU usage setup. The only solution in this situation (when you need parameters like cpuset and runtime) would be to run containers manually or move to something like Kubernetes.

Here are compose files examples:

Version 3.7 (working)

version: '3.7'

services:

  mongo:
    image: mongo
    volumes:
      - ~/ProcessingServerData/mongodb/db:/data/db
      - ~/ProcessingServerData/mongodb/configdb:/data/configdb
    networks:
      - proc-net
    
  mongo-express:
    image: mongo-express
    depends_on:
      - mongo
    ports:
      - 8081:8081
    networks:
      - proc-net
  
  visualizer:
    image: dockersamples/visualizer:stable
    ports:
      - 8082:8080
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - proc-net
    deploy:
      placement:
        constraints: [node.role == manager]

networks:
  proc-net:
    driver: overlay
    attachable: true

Version 2.4 (not working)

version: '2.4'

services:

  mongo:
    image: mongo
    volumes:
      - type: bind
        source: ~/ProcessingServerData/mongodb/db
        target: /data/db
      - type: bind
        source: ~/ProcessingServerData/mongodb/configdb
        target: /data/configdb
    networks:
      - proc-net
    deploy:
      resources:
        cpuset: 0,1
    
  mongo-express:
    image: mongo-express
    depends_on:
      - mongo
    ports:
      - 8081:8081
    networks:
      - proc-net
    deploy:
      resources:
        cpuset: 0,1
  
  visualizer:
    image: dockersamples/visualizer:stable
    ports:
      - 8082:8080
    volumes:
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
    networks:
      - proc-net
    deploy:
      resources:
        cpuset: 0,1
      placement:
        constraints: [node.role == manager]

networks:
  proc-net:
    driver: overlay
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Annie Owl
  • 1
  • 2
  • The point of the version 3 format is that some options are not supported with swarm mode, so those options are removed in version 3 and swarm mode requires that version for the features it supports. – BMitch Mar 05 '20 at 16:32

2 Answers2

0

deploy config option is not supported in 2.4 , you need to change the file to this one

version: '2.4'

services:

  mongo:
    image: mongo
    volumes:
      - type: bind
        source: ~/ProcessingServerData/mongodb/db
        target: /data/db
      - type: bind
        source: ~/ProcessingServerData/mongodb/configdb
        target: /data/configdb
    networks:
      - proc-net

  mongo-express:
    image: mongo-express
    depends_on:
      - mongo
    ports:
      - 8081:8081
    networks:
      - proc-net

  visualizer:
    image: dockersamples/visualizer:stable
    ports:
      - 8082:8080
    volumes:
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
    networks:
      - proc-net

networks:
  proc-net:
    driver: overlay

Al-waleed Shihadeh
  • 2,697
  • 2
  • 8
  • 22
  • Sadly this is not a solution for my problem. According to this post only Version 3+ is supported for deploy on a newer docker version: https://forums.docker.com/t/cant-deploy-stack-with-compose-file-version-2-4-on-docker-19-03-6/90119 – Annie Owl Mar 05 '20 at 15:56
  • You can not use the `deploy` with 2.4, here you have only two options. 1- use 2.4 and get rid of the `deploy` part, 2- upgrade to v3 – Al-waleed Shihadeh Mar 05 '20 at 16:12
  • Yes, I understand it now. Thank you for the answer. – Annie Owl Mar 05 '20 at 16:16
0

Apparently there is no support for an older compose file version for deploy. https://forums.docker.com/t/cant-deploy-stack-with-compose-file-version-2-4-on-docker-19-03-6/90119

Annie Owl
  • 1
  • 2