Docker Community Forums

Share and learn in the Docker community.

How to specify a container runtime in a swarm

(Sanlabkevin) #1

One of the containers in my swarm needs to use a specific runtime value (the equivalent of the —runtime argument in the Docker run command). Is there a way to specify this value in the docker-compose.yml file?

(Sonicsea) #2

You can use docker configs. Something like this:

    image: [image-name]:[tag]
      replicas: 2
      - my_config
    file: ./my_config.txt

By default, the container can access the config from “/my_config”

(Sanlabkevin) #3

Hi sonicsea,

Thanks for the suggestion. From what I can tell, this only exposes a file in the container’s file system which you can then use for configuration purposes. It doesn’t look like I would be able to set the container’s runtime. Just to clarify, in my compose file, I need to recreate something like this:

docker run --runtime=nvidia nvidia/cuda /bin/bash


(Shappenny) #4

Hey sanlabkevin, did you ever find out if this is possible? I haven’t been able to find any way to do this.