简体   繁体   中英

Run executable from host within docker container

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 eg 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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM