How to remount the /proc filesystem in a docker as a r/w system?
10,471
If the goal is to set sysctl settings, docker has realized the issue and in 1.12+ you can use the --sysctl flag when running a docker container (or in your compose file) which will set the values inside the container before it is run.
This is sadly not (yet) integrated yet in the dockerfile syntax.
docker run --sysctl kernel.shmmax=1073741824 yourimage
Example docker-compose.yml (must use version 2.1):
version: '2.1'
services:
app:
sysctls:
- kernel.shmmax=1073741824
Author by
Admin
Updated on June 16, 2022Comments
-
Admin almost 2 years
I have installed docker 0.11.1 over Ubuntu 12.04. I am trying to change the shmmax from its fixed value (32 M) to something bigger (1G) from within the docker when I run the command:
sysctl -w kernel.shmmax=1073741824 error: "Read-only file system" setting key "kernel.shmmax"
That is because
/proc
is mountedro
in the container.Can someone tell me how to mount the proc as
r/w
in my container to change it? -
user207421 almost 10 years'Had some luck' isn't an answer, and neither is an unexplained command sequence.
-
marathon over 9 yearsin docker, this gives "permission denied", even as root.
-
TrinitronX almost 8 yearsThis appears to work only if you have run the container with
--privileged
mode. However, it does work when in that mode. -
DavidG over 2 yearsWhile not exactly the same, I just had a similar issue in Kubernetes using Docker containers. The /proc virtual filesystem was mounted ro in my container and I needed it to be rw. I solved it by adding "securityContext: { privileged: true }" to the kubernetes container specification. That allowed me to execute "mount -o remount,rw /proc " which was previously failing.