How to specify Memory & CPU limit in docker compose version 3

I am unable to specify CPU and memory limitation for services specified in version 3.

With version 2 it works fine with mem_limit & cpu_shares parameters under the services. But it fails while using version 3, putting them under deploy section doesn’t seem worthy unless I am using swarm mode.

Can somebody help?

    version: "3"
    services:
      node:
        build:
         context: .
          dockerfile: ./docker-build/Dockerfile.node
        restart: always
        environment:
          - VIRTUAL_HOST=localhost
        volumes:
          - logs:/app/out/
        expose:
          - 8083
        command: ["npm","start"]
        cap_drop:
          - NET_ADMIN
          - SYS_ADMIN

4 Answers
4

Leave a Comment