Skip to content

Addition of "--shm-size" to which size of /dev/shm is changed - #16168

Merged
LK4D4 merged 1 commit into
moby:masterfrom
NIWAHideyuki:16164-shm-size
Nov 20, 2015
Merged

LK4D4 merged 1 commit into
moby:masterfrom
NIWAHideyuki:16164-shm-size

Conversation

@NIWAHideyuki

Copy link
Copy Markdown

Addition of "--shm-size" to which size of /dev/shm is changed.
It relates to #2606 , #3505 and #4981.

fix #2606
fix #3505
fix #4981

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

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

@cpuguy83

cpuguy83 commented Sep 9, 2015

Copy link
Copy Markdown
Member

Looks like you need to run gofmt -s -w on your changes.
Also tests would be helpful.

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Sep 10, 2015
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Sep 11, 2015
@bastih

bastih commented Sep 11, 2015

Copy link
Copy Markdown

Can we have this for docker build as well?

@NIWAHideyuki

Copy link
Copy Markdown
Author

The size of shm is specified into "run and create".
I would like to try "build" next.

@bastih

bastih commented Sep 14, 2015

Copy link
Copy Markdown

That would be awesome, we are currently using a custom build just to adjust shared memory during build time so we can run a program that needs more than the default amount of shared memory. Would be lovely to remove our hard-coded customizations.

@NIWAHideyuki
NIWAHideyuki force-pushed the 16164-shm-size branch 2 times, most recently from eb72c60 to 24acf55 Compare September 16, 2015 23:56
@NIWAHideyuki NIWAHideyuki mentioned this pull request Sep 17, 2015
@NIWAHideyuki
NIWAHideyuki force-pushed the 16164-shm-size branch 10 times, most recently from 3bf2e9e to 57ecd52 Compare October 2, 2015 00:14
@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Oct 2, 2015
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Oct 2, 2015
@NIWAHideyuki
NIWAHideyuki force-pushed the 16164-shm-size branch 2 times, most recently from ab3a634 to 740e665 Compare October 2, 2015 07:43
@jessfraz

jessfraz commented Oct 2, 2015

Copy link
Copy Markdown
Contributor

lets do run and create for now, design lgtm moving to code review

@NIWAHideyuki

Copy link
Copy Markdown
Author

Thanks,
I am able to use /dev/shm in docker.
I'm happy.

@vtintillier

Copy link
Copy Markdown

Can it be used automatically in Docker Compose, or is another change required for this option to be available in compose?

@thaJeztah

Copy link
Copy Markdown
Member

@vtintillier that probably requires changes in docker compose, so I suggest to open an issue in that repository and refer to this pull request

Comment thread daemon/container_unix.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the behavior here isn't consistent between cli and api though..on the cli (build,run,create) we error out if <= 0, API will just default to 64MB
I think either both error out or they set a default

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take this back sorry for the noise

@lifubang

Copy link
Copy Markdown
Contributor

I have to run a bash script in /dev/shm, but the server said 'Permission denied'.
When I use mount command, the result is:
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1048576k)
My question is how to make /dev/shm have exec permission?
Thanks.

我修改了源代码,把NOEXEC去掉了,可以了。
建议下一版能提供NOEXEC的开关。

@grooverdan

Copy link
Copy Markdown
Contributor

@lifubang - currently not possible - https://github.com/docker/docker/blob/master/daemon/container_operations_unix.go#L1048 - raise a separate issue if you can't find one already. Issues aren't a support request forum.

@grooverdan

Copy link
Copy Markdown
Contributor

@lifubang #18855 #18853 (comment)

@kopax

kopax commented Jun 28, 2016 •

Copy link
Copy Markdown

--shm-size=512m is not working for me as build args, either as run args.

            docker run -it --shm-size=102400 ubuntu:14.04.4
    root@141a66888d0a:/# cat /proc/mounts | grep shm
    shm /dev/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=100k 0 0
    root@141a66888d0a:/# ipcs -lm

    ------ Shared Memory Limits --------
    max number of segments = 4096
    max seg size (kbytes) = 32768
    max total shared memory (kbytes) = 8388608
    min seg size (bytes) = 1

Install details

    docker version
    Client:
     Version:      1.11.0
     API version:  1.23
     Go version:   go1.5.4
     Git commit:   4dc5990
     Built:        Wed Apr 13 18:17:17 2016
     OS/Arch:      linux/amd64

    Server:
     Version:      1.11.0
     API version:  1.23
     Go version:   go1.5.4
     Git commit:   4dc5990
     Built:        Wed Apr 13 18:17:17 2016
     OS/Arch:      linux/amd64


    uname -a
    Linux master-bhs-01 3.14.32-xxxx-grs-ipv6-64 #7 SMP Wed Jan 27 18:05:09 CET 2016 x86_64 GNU/Linux

I have tried lot's of way to set this value and I am completely stuck finding no way to configure it for using with gitlab.

I have started this issue, I post it here because it's a bit related to what I am trying to achieve : https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1381

@thaJeztah

Copy link
Copy Markdown
Member

@kopax can you open a new issue for that? it's ok to add a link to this PR for reference

@kopax

kopax commented Jun 28, 2016

Copy link
Copy Markdown

Sure, here is the topic : #24040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bigger /dev/shm