问题
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