Mount /dev/shm with exec option in Swarm Mode

Hi Docker Users,

I’m running Docker version 18.03.1-ce, build 9ee9f40 on Ubuntu 16.04. I have an MPI application running in a container which requires /dev/shm to be mounted as a tmpfs with the exec flag. When launching a standalone container I can use:

docker run --name my-container -v /dev/shm --tmpfs /dev/shm:rw,nosuid,nodev,exec,size=90g my-image

and everything works fine. However, I would like to deploy several such containers as part of a stack distributed across multiple physical hosts. I cannot figure out how to mount /dev/shm as a tempfs with the options stipulated above when using a docker-compose.yml file and docker stack deploy. It’s not strictly necessary to use Docker Stack - I just need containers to be communicating on the same network so that it is possible to ssh between them. I’m a docker newbie so please let me know if there’s any additional information that will help clarify my question.