Can't deploy stack with compose file version 2.4 on docker 19.03.6

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?

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

According release notes for docker-compose 1.25.4 it support compose file format 2.4 on docker engine version 17.12.0+.

Though, “deploy” is not compliant according the v2 file reference.
In order to deploy swarm stacks, you need to use v3+.

Be aware that not all features of plain docker (as in docker-compose and docker run) are supported by swarm service/stacks. Especialy low level features are missing…

1 Like

Yeah, it’s really sad that there is no support for runtime and cpuset. Thank you for the answer.

If you want full control of your deployments, there is no way arround kubernetes for time beeing.