如何指定要在docker-compose版本3中使用的容器运行时? [英] How can I specify the container runtime to use in docker-compose version 3?
问题描述
我正在一个需要nvidia运行时的容器上工作.我可以在v2.3 docker-compose文件中指定此运行时,如下所示:
I'm working on a container that requires the nvidia runtime. I can specify this runtime in a v2.3 docker-compose file like so:
version: "2.3"
services:
my-service:
image: "my-image"
runtime: "nvidia"
...
运行 docker-compose up my-service
效果很好.我得到了nvidia运行时,一切正常.
Running docker-compose up my-service
works just fine. I get the nvidia runtime and everything works fine.
我只是通过将"2.3"更改为"3"来尝试此操作,当我执行 docker-compose up my-service
时,出现以下错误:
I've tried this just by changing the "2.3" to "3" and I get the following error when I do docker-compose up my-service
:
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.my-service: 'runtime'
如果我删除了 runtime:"nvidia"
行,这将毫无问题地出现-除非它不使用nvidia,而且我需要访问主机上的GPU才能获得性能想要.
If I take out the runtime: "nvidia"
line, this comes up without problems—except of course it's not using nvidia and I need access to the GPU on the host to get the performance I want.
docker-compose v3中的 runtime
是否等效?如果没有,为什么放弃该选项?提前致谢.:)
Is there an equivalent for runtime
in docker-compose v3? If not, why was this option dropped? Thanks in advance. :)
推荐答案
我意识到这个问题比较老,但是昨天我碰到了这个问题.
I realize this question is rather old but I ran into it yesterday.
TL; DR:将您的docker-compose升级到1.27.0 +
TL;DR : Upgrade you docker-compose to 1.27.0+
详细信息
关于专用Docker错误线程中 runtime
关键字的删除已有相当多的讨论:
There has been quite a discussion about the removal of the runtime
keyword in the dedicated Docker bug thread : https://github.com/docker/compose/issues/6691
最后,在1.27.0中,Docker决定允许它返回.因此,您只需要拥有正确版本的docker-compose.
Finally, in the 1.27.0, Docker has decided to allow it back. So you just need to have the correct version of docker-compose.
我建议使用pip安装路径,因为它们的版本是最新的(Debian buster中的当前docker-compose版本为1.21).似乎还有其他好的原因为此,请参见此处.
I would recommend the pip install path as their versions are more up to date (current docker-compose version in Debian buster is 1.21). And it seems there are other good reasons to do so, see here.
这篇关于如何指定要在docker-compose版本3中使用的容器运行时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!