moby / moby

The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

Home Page:https://mobyproject.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bigger /dev/shm

kohlerm opened this issue · comments

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.

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

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 notifications@github.comwrote:

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
.

Hi.

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

Kim

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

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

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

Maybe this issue should be reopen?

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.

ping: reopen please

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

proposing #3505 as a fix

@crosbymichael can we start working on ths issue or the lxc driver is still under major rework?

+1 for this issue, ran into the same same problem in the same context (trying to run oracle-xe in docker)

[OFF_TOPIC] https://github.com/mproch/docker-oracle-xe allows you to install oracle in docker (by commenting out memory_target=1073741824 in the "init.ora" file). I'm not exactly sure how that impacts oracle performance yet

Any updates on this? For me it's not Oracle but ABBYY OCR which occasionally needs a bigger /dev/shm...

do any of the workarounds work for docker 1.3.x? also need this

I just tried it again, and it still does not seem to work.
The only workaround I found was to mount more shm in privileged mode.
After fiddling around quite some time , I created the docker image manually.

Isn't this "just" that we need a configurable knob for the size of /dev/shm in create/run?

For the record, the main place this is currently hard-coded that I can find is https://github.com/docker/libcontainer/blob/14a7d2f468404e25577dced6982248e80ddce79a/nsinit/config.go#L261.

I don't know about the others, but for me (ABBYY OCR inside a docker container) just having this size configurable (without having to run the container privileged) would be a perfect solution.

I agree making it configurable would help a lot. If there would be a privileged mode for docker build I could also work around this issue

This is from #3505

"Added a "docker run" option for sizing /dev/shm which is actually
hardcoded to 64M.

The option is -shm="xxx" where xxx is the size in bytes using k,m,g
notation.

Docker-DCO-1.0-Signed-off-by: Julien Vermillard jvermillar@sierrawireless.com (github: jvermillard)"

This seems to be a good fix to the constraints put on /dev/shm.

How does this get rolled into the centos 6.6 docker build? Could really use this fix/feature. I do not want to run in privileged mode. Thanks.

@rongearley, I think you mean: #3505

Yes, thx. Edited my comment.

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 niwa.hiedyuki@jp.fujitsu.com

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

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

@NIWAHideyuki Awesome - what release will it be in?

@NIWAHideyuki I would also like to know that

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

@thaJeztah Awesome - thanks!

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

Is it possible to set this persistently in Docker Cloud?

@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

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

@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