Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase /dev/shm in docker container in swarm environment (docker stack deploy)

I know is possible to increase default 64MB /dev/shm in docker container from docker run or docker compose. As example this works in our local development machines.

version: '3.5'
services:
  postgres:
    image: postgres
    shm_size: '1gb'

However when I try to do it in our swarm docker stack deploy stack_name -c docker-compose.yml I get a "Ignoring unsupported options: shm_size" and shm mount remains as default 64MB.

What can I do? I tried to create an image with this parameter but it seems is not something that I can add to image built, more like a runtime option. It's possible to modify it after container creation?

Environment is an Ubuntu 16.04 with docker 17.12 in a single node swarm.

like image 315
Gonzalo Cao Avatar asked Mar 29 '19 11:03

Gonzalo Cao


1 Answers

You can add the following code in docker-compose.yml. It will directly add a tmpfs volume targetting /dev/shm:

volumes:
      - type: tmpfs
        target: /dev/shm
        tmpfs:
           size: 4096000000 # (this means 4GB)
like image 128
Tony Qu Avatar answered Oct 13 '22 17:10

Tony Qu