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

I know the topic is a bit old and seems stale, but anyway I was able to use these options:

deploy:
  resources:
    limits:
      cpus: '0.001'
      memory: 50M

when using 3.7 version of docker-compose

What helped in my case, was using this command:

docker-compose --compatibility up

--compatibility flag stands for (taken from the documentation):

If set, Compose will attempt to convert deploy keys in v3 files to
their non-Swarm equivalent

Think it’s great, that I don’t have to revert my docker-compose file back to v2.

Leave a Comment