How to increase the size of the /dev/shm in docker container

后端 未结 4 1698
渐次进展
渐次进展 2020-12-14 05:47

Currently When I create new docker container the size of the shared memory directory is limited to 64MB. But, I need to increase this size since my application depend on thi

相关标签:
4条回答
  • 2020-12-14 06:07

    If you're using docker-compose, you can set the your_service.shm_size value if you want your container to use that /dev/shm size when running or your_service.build.shm_size when building.

    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 source.

    0 讨论(0)
  • 2020-12-14 06:07

    If you use docker-compose to set up your docker environment, it is also possible to set the shared memory in the docker-compose.yml configuration file (since the 3.5 version of the file format):

    build:
      context: .
      shm_size: '2gb'
    

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

    0 讨论(0)
  • 2020-12-14 06:11

    If anybody is using an older docker version prior 1.10.0 and cannot upgrade for some reason, there is a workaround I used to set shm-size which works fine for me (you need sudo-rights to create the mount on the host):

    sudo mkdir /mnt/dockershm
    sudo mount -t tmpfs -o size=1G tmpfs /mnt/dockershm
    docker run -d -v /mnt/dockershm:/dev/shm dockerimagetorun:latest
    
    0 讨论(0)
  • 2020-12-14 06:16

    You can modify shm size by passing the optional parameter --shm-size to docker run command. The default is 64MB.

    eg:

    docker run -it --shm-size=256m oracle11g /bin/bash
    
    0 讨论(0)
提交回复
热议问题