Docker-compose: how to do version 2 “mem_limit” in version 3?

随声附和 提交于 2021-01-28 02:54:20

问题


Recently, I tried upgrading a version 2 docker-compose yaml file to version 3. Specifically, I was going from 2.1 to 3.4. Using docker-compose version 1.18.0 and docker version 18.06.01.

The first attempt caused docker-compose to abort because of the presence of the Version 2 option: mem_limit. Reading these Version 3 docs, it clearly states mem_limit was removed and to see "upgrading" to guide usage away from this option. These instruction tell you to use the deploy section with resources. Making these changes to the docker-compose.yml file and the system started normally.

Unfortunately, I missed the disclaimer in there where it states that deploy is ignored by docker-compose! My question: is there a way to use Compose file reference 3 and docker-compose while still enforcing a container memory limit?


回答1:


No, there is not.

And also you don't have to upgrade, you don't even have any reason to upgrade if you don't use swarm.

Sadly in the official docker docs, there is stated

Version 3 (most current, and recommended)

which isn't actually really true, if you use docker-compose without swarm, there is hardly any reason to switch or to use on new project v3. In the official repository you can see comments like this https://github.com/docker/compose/issues/4513#issuecomment-281478365 or https://github.com/docker/compose/issues/5586#issuecomment-375577458.

Also in the compatibility-matrix you can see that v2 is still upgraded even when v3 is out for quite some time.



来源:https://stackoverflow.com/questions/53635512/docker-compose-how-to-do-version-2-mem-limit-in-version-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!