How can I specify the container runtime to use in docker-compose version 3?

断了今生、忘了曾经 提交于 2021-01-27 06:06:25

问题


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"
    ...

Running docker-compose up my-service works just fine. I get the nvidia runtime and everything works fine.

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'

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.

Is there an equivalent for runtime in docker-compose v3? If not, why was this option dropped? Thanks in advance. :)


回答1:


I realize this question is rather old but I ran into it yesterday.

TL;DR : Upgrade you docker-compose to 1.27.0+

Details

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

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.

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.



来源:https://stackoverflow.com/questions/59033632/how-can-i-specify-the-container-runtime-to-use-in-docker-compose-version-3

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