Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount tmpfs when using docker stack

When deploying a standalone container I can mount /dev/shm as a tmpfs with custom options as follows:

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

However, I cannot figure out how to do the same thing when deploying a container over a swarm using docker stack deploy. There does not appear to be any relevant information in the documentation here. With the following docker-compose.yml

version: '3.6'
services:
  master:
  image: "my-image"
  ports:
   - "8080:8080"
  volumes:
   - type: tmpfs
     target: /dev/shm

/dev/shm is mounted with default options. How can I mount /dev/shm with the options (rw,nosuid,nodev,exec,size=90g) using docker stack deploy?

like image 558
aht Avatar asked May 09 '18 01:05

aht


1 Answers

Reading the docs here, --tmpfs can only be used with standalone containers, for services use --mount:

--tmpfs: Mounts a tmpfs mount without allowing you to specify any configurable options, and can only be used with standalone containers

Difference between --tmpfs and --mount described here:

  • The --tmpfs flag does not allow you to specify any configurable options.

  • The --tmpfs flag cannot be used with swarm services. You must use --mount.

like image 151
namokarm Avatar answered Oct 12 '22 06:10

namokarm