-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --shm-size to docker container update #1278
Comments
It's not really easily done on a running container, so it could only take effect on container restart. |
@cpuguy83 because of some reasons:
If there are use cases for changing other container configurations inside |
If you need persistent state, please consider using a volume for this. This would allow you to attach the same volume to a different container. It is also significantly more performant if that is at all needed. All other options can be updated while a container is running. Mounts cannot. |
@cpuguy83 , I have similar issue. I have container that I created without use of volumes unfortunately. And each time I start it I have to perform Changing start configuration of container makes sense even if effect will be during next start. Ideally Right now work-around is:
Note that though generic mounts changes might not be achievable with running container there still should be a way to change # outside of container
mount -o remount,size=500m '/var/lib/docker/containers/.../mounts/shm' |
These suggestions do not work for version 19.03. |
Make sure, that docker service is stoped, before modify hostconfig.json. |
The fast and ditry solution for all who want to increase shm in runtime without recreating daemon.
Unless your application spawns processes in different namespaces, you shoud be fine. DO NOT USE THIS IN PRODUCTION |
Description
I'd like to easily change the
shm-size
in a running container by usingdocker container update
. I'm running PostgreSQL inside a container and receiving an error related to the small amount of shared memory available.Steps to reproduce the issue:
--shm-size
Describe the results you received:
I've found two ways of changing the shared memory of a running container:
Remount the shm file system of the container:
mount -o remount,rw,nosuid,nodev,noexec,relatime,size=256M -t tmpfs /var/lib/docker/containers/<container-id>/mounts/shm
. Ifshm
is not found inside this path, try usingnsenter
as explained in Add --shm-size to docker container update #1278 (comment)Change
ShmSize
inside/var/lib/docker/containers/<container-id>/hostconfig.json
and restart container. EDIT: as noted by @dmitrygashnikov: you must stop docker service (service docker stop
), then change thehostconfig.json
file for this container and start docker again (service docker start
).The second option is the only one which makes the change persistent, but we need to stop all running containers to make the change.
Here is a little script to change
/dev/shm
(by default to1GB
), using the docker daemon restart method:Describe the results you expected:
It would be awesome to change this setting from the command line, using
docker container update --shm-size=256M
.Output of
docker version
:The text was updated successfully, but these errors were encountered: