Limit resources in docker-compose v3

后端 未结 3 1105
[愿得一人]
[愿得一人] 2020-12-29 04:29

mem_limit is no longer supported in version 3 of docker-compose.yml file. The documentation tells that I should use the deploy.resources key instead but also th

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 04:36

    I was searching for this issue a while ago. I have found my answer here. At first, I tried to implement this functionality without using docker stack, but that did not work.

    Here is the piece of code which you would use to limit container's CPU/memory consumption. For additional attributes, you can search the documentation of docker.

     deploy:
      replicas: 5
      resources:
        limits: 
          cpus: "0.1"
          memory: 50M
    

    Compose file does not recognize deploy attributes, unless you deploy the application as a stack.

提交回复
热议问题