I need to mount a volume for the /sys to make that piece read-write to adjust the transparent pages to run TokuDB.
I must have that magic done within a Dockerfile, and using VOLUME will give me an empty /sys. I need to have a way to mount a volume under the OS files added by default to /sys.
With a docker run command, I can do it as below:
docker run -it \
--volume=/sys:/sys:rw \
ubuntu:latest
My question is, how can I do it using the Dockerfile?
Thanks, folks.
CodePudding user response:
You can't.
The setting you're trying to change is a kernel-level setting, that will affect all other containers and all other non-container processes on the host. That means Docker will generally prevent a container from changing it at all. An image also can't grant itself permission to make changes to the host system; you can't ever specify a host directory in a Dockerfile VOLUME
directive.
I would not try to make this change in your container. Use sysctl
on the host system as root. You should be able to include a startup-time check and warn if the value isn't set correctly, and this would also be a good thing to document in your source repository's README.md
file.
CodePudding user response:
I geuss you want to copy, so in the dockerfile add:
COPY /sys /sys
To copy it from your host into the container.