Skip to content

bigger /dev/shm #2606

Closed
Closed

Description

@kohlerm

I need to increase the size of /dev/shm which seems to be hardcoded to 64Mbyte
in
lxc_template.go

Is it correct that I have to change the value there and recompile docker to get a different value?
It would be helpful to be able to configure it per instnace, e.g some Databasesdo not install without enough shared memory.

Activity

  1. tianon commented on Nov 8, 2013

    @tianon
    Member

    Have you tried just overwriting it with -lxc-conf?

  2. kohlerm commented on Nov 9, 2013

    @kohlerm
    Author

    Thanks, i was not Aware of this Option!
    I rebuild my
    docker works fine!
    Markus

    On Fri, Nov 8, 2013 at 3:51 PM, Tianon Gravi [email protected]:

    Have you tried just overwriting it with -lxc-conf?

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/2606#issuecomment-28067688
    .

  3. kimsandb commented on Nov 14, 2013

    @kimsandb

    Hi.

    What actual options would do this? I'm having issues with the rootpath.

    Kim

  4. jvermillard commented on Nov 23, 2013

    @jvermillard

    same here, kohlerm do you mind shring the command line you used?

  5. jvermillard commented on Nov 23, 2013

    @jvermillard

    I tried

    docker run -i -lxc-conf="lxc.mount.entry=shm /dev/shm tmpfs size=2G,nosuid,nodev,noexec 0 0" -t  ca0ab8243b6a /bin/bas
    

    without success

    In the resulting /proc/mounts :

    shm /dev/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=65536k 0 0
    
  6. kohlerm commented on Nov 24, 2013

    @kohlerm
    Author

    I haven't tried yet, but just use a recompiled docker. Turned out to be easy because docker compiliation is done using a docker image!
    I will try to figure out how it works with the command line within the next few days

  7. jvermillard commented on Nov 25, 2013

    @jvermillard

    Maybe this issue should be reopen?

  8. kohlerm commented on Dec 6, 2013

    @kohlerm
    Author

    does not work in 0.7 as well.
    I think it might not work because the line in the template contains
    {{escapeFstabSpaces $ROOTFS}}/

    which is expanded to the full /var/lib/docker path.

  9. jvermillard commented on Dec 12, 2013

    @jvermillard

    ping: reopen please

  10. reopened this on Dec 12, 2013
  11. tianon commented on Dec 12, 2013

    @tianon
    Member

    Yes, it would appear that we need some way to tweak this value, since lxc-conf can't do it.

  12. jvermillard commented on Jan 8, 2014

    @jvermillard

    proposing #3505 as a fix

  13. 24 remaining items

  14. NIWAHideyuki commented on Sep 17, 2015

    @NIWAHideyuki

    Hi,
    I hope for the function that the shm memory of a size that is bigger than 64MB can be set.
    And, I tried to make it. #16168

    Addition of "--shm-size" to which size of /dev/shm is changed when container is made.

    • Optional "--shm-size=" was added to the run sub-command.
    • The size of /dev/shm in the container can be changed when container is made.
    • Being able to specify is a numerical value that applies number, b, k, m, and g.
    • The default value is 64MB, when this option is not set.
    • It deals with both native and lxc drivers.

    Example)

    docker run -it --shm-size=256m centos /bin/sh

    Signed-off-by: NIWA Hideyuki [email protected]

  15. davidkarlsen commented on Oct 14, 2015

    @davidkarlsen

    How to apply this when building images (not running), e.g. docker build?

  16. NIWAHideyuki commented on Oct 15, 2015

    @NIWAHideyuki

    I newly applied optional --shm-size to "docker build" sub command.

  17. davidkarlsen commented on Oct 15, 2015

    @davidkarlsen

    @NIWAHideyuki Awesome - what release will it be in?

  18. awartoft commented on Oct 23, 2015

    @awartoft

    @NIWAHideyuki I would also like to know that

  19. thaJeztah commented on Nov 23, 2015

    @thaJeztah
    Member

    @davidkarlsen @macnibblet the PR was just merged (#16168) and will be part of the 1.10 release

  20. davidkarlsen commented on Nov 23, 2015

    @davidkarlsen

    @thaJeztah Awesome - thanks!

  21. mansurali901 commented on Jul 15, 2016

    @mansurali901

    Temporary increase tmpfs filesystem

    1. Open /etc/fstab with vi or any text editor of your choice,
    2. Locate the line of /dev/shm and use the tmpfs size option to specify your expected size,
      e.g. 512MB:
      tmpfs /dev/shm tmpfs defaults,size=512m 0 0
      e.g. 2GB:
      tmpfs /dev/shm tmpfs defaults,size=2g 0 0

    mount -o remount /dev/shm

  22. davidthornton commented on Jul 26, 2017

    @davidthornton

    Is it possible to set this persistently in Docker Cloud?

  23. Eyshika commented on Jul 10, 2019

    @Eyshika

    @mansurali901 your method works in the host machine, it doesnt work for docker container. i tried same method but it gives me permission denied error for mount -o remount /dev/shm . i ran it with sudo as well but still container memory is same

  24. mansurali901 commented on Jul 10, 2019

    @mansurali901

    @Eyshika this is happening because your container is working in un privileged mode if you run your container with --privilege mode this will work

  25. thaJeztah commented on Jul 10, 2019

    @thaJeztah
    Member

    @Eyshika @mansurali901 I would highly recommend avoiding the use of --privileged as it will disable (if not all) all protection that containers provide. If you want to set the size for the container, docker run has a --shm-size option. You can also use the --mount option, which allows you to set options for swarm services as well (see #26714 (comment)) for example:

    docker run -it --rm \
      --name tmpfstest \
      --mount type=tmpfs,dst=/dev/shm,tmpfs-size=1000000000 \
      alpine

    Inside the container:

    / # df -h /dev/shm
    Filesystem                Size      Used Available Use% Mounted on
    tmpfs                   953.7M         0    953.7M   0% /dev/shm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    exp/expertkind/enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions