Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remount the /proc filesystem in a docker as a r/w system?

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 mounted ro in the container.

Can someone tell me how to mount the proc as r/w in my container to change it?

like image 967
upendra Avatar asked May 24 '14 02:05

upendra


People also ask

What is Docker bind mount?

Bind mounts have been available in Docker since its earliest days for data persisting. Bind mounts will mount a file or directory on to your container from your host machine, which you can then reference via its absolute path. To use bind mounts, the file or directory does not need to exist on your Docker host already.

How do I mount a volume in running Docker container?

Cloning From An Existing Container But, if you do need to add a volume to a running container, you can use docker commit to make a new image based on that container, and then clone it with the new volume. Then, you can run the new image, replacing the old image with the cloned one.


1 Answers

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.

https://docs.docker.com/engine/reference/commandline/run/#configure-namespaced-kernel-parameters-sysctls-at-runtime

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
like image 184
tweak2 Avatar answered Sep 28 '22 05:09

tweak2