10

I have a docker container and I would like to start a process in the host OS, and then have it execute in the context of the docker container. That is, my executable is a file in the host filesystem, and I want to start a process in the host OS, but I want to contain that process to the container, so that e.g. the process can only access the container's filesystem, etc.

For various reasons I do not want to copy the executable into the container and execute it there.

I do realize that this is a somewhat strange thing to be trying to do with docker containers!

4
  • how about mounting that directory to the container using volume and then executing the executables using docker exec .. in the running container? Commented May 21, 2015 at 0:23
  • Thanks, but I'm actually trying to protect the external filesystem from begin accessed by the process running within the container so I that wouldn't work for me. Commented May 21, 2015 at 0:44
  • If you only care about filesystem, why not use chroot? Commented May 21, 2015 at 0:58
  • I'm concerned about security and was led to believe that chroot is not considered secure. Is that not so? Commented May 21, 2015 at 1:00

1 Answer 1

10

Mount the executable into the container with a volume like this:

$ docker run -v /path/to/executable:/my_exe debian /my_exe

The only problem is you will also need to take care of making sure any required libraries are also available in the container.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.