How to increase size / dev / shm in docker container

Currently, when I create a new docker container, the shared memory directory size is limited to 64 MB. But I need to increase this size as my application depends on this shared memory. Is there a way to increase the size of / dev / shm in the docker container? I heard that 64 MB is hard-coded in docker code, how to install docker from source and change the value of / dev / shm?

+14
source share
3 answers

You can change the size by --shm-sizepassing an optional parameter --shm-sizeto the command docker run. The default value is 64 MB.

eg:

docker run -it --shm-size=256m oracle11g /bin/bash
+12
source

docker-compose docker, docker-compose.yml ( 3.5 ):

build:
  context: .
  shm_size: '2gb'

: https://docs.docker.com/compose/compose-file/#shm_size

+9

If you use docker-compose, you can set the value your_service.shm_sizeif you want your container to use this size / dev / shm at startup or your_service.build.shm_sizeat build.

Example:

version: '3.5'
services:
  your_service:
    build:
      context: .
      shm_size: '2gb' <-- this will set the size when BUILDING
    shm_size: '2gb' <-- when RUNNING 

Link to the source .

0
source

Source: https://habr.com/ru/post/1016509/


All Articles