4

without using volumes -v

I can add --privileged to docker run but I can't mount arbitrary volumes because I depend on another tool to create docker containers so my question is how can I get full access to the docker host file system with --privileged=true, is that enough?

In particular need to access the host /run/ from within the docker container. I can also include --cap-add so that may help. The only thing I can't do is to mount volumes.

7
  • You should use volumes, see the docs docs.docker.com/userguide/dockervolumes for example docker run -v /run:/run Commented Jun 28, 2015 at 13:23
  • As tried to express in the question, I'm not in control of the docker run command and can't add -v but I can do other things like set privileged true or even enable any Linux capability. Commented Jun 28, 2015 at 18:57
  • Do you have to mount the /run directory, or is it enough to be able to copy to/from it? Commented Jun 28, 2015 at 20:45
  • I need read/write access Commented Jun 28, 2015 at 21:13
  • 1
    I'm looking for a knowledgeable answer rather than a "In theory" Commented Jan 7, 2016 at 12:51

1 Answer 1

4

I was facing the similar situation. I wanted to access the full filesystem of host, from the privileged container itself. The way I did it was to change the namespace to host namespace then execute a command. That command actually acts on host.

Run on host to start container:

docker run --privileged --pid=host -it xxxxxx

Run in container

nsenter -t 1 -m -u -n -i <COMMAND>

The COMMAND will be executed on host.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.