parameter to specify runtime to build image
Description
Use Case
Build an image with specific runtime (e. g. nvidia-runtime).
Current Situation
Currently if during building an image a specific runtime is required the default runtime must be set to the required runtime (e. g. specify nvidia-runtime as default runtime in /etc/docker/daemon.json).
This also has the side effect of changing the runtime of every container, where no explicit runtime is given.
There already exists a runtime directive in the docker-compose.yml, which specifies the runtime to use for container execution (i. e. not for building the image).
Feature
Make it possible to specify the runtime to use for building the image in docker-compose.yml. So that the change of the server configuration is not needed and hence the mentioned side effect does not occur.
In other words: enable users to build with a specific runtime-requirement without changing the server's default-runtime in daemon.json.
Alternatives
- use the runtime specified by the
runtimedirective indocker-compose.ymlalso for the build-phase - introduce a new directive
runtimebelow thebuilddiretive indocker-compose.yml
The latter seems to have minimal changes to the API.
If such a feature exists on Bake (github.com/docker/buildx) we would add support for it. AFAICT build process doesn't ket you select a container runtime but offers platform abstraction to achieve a comparable purpose
Closing as "not planned" - compose only can expose features supported by the builder.