How can I access the host from the container? For example, I want to run a script on the host? are there any other ways to do this ? I thought only of SSH? are there other ways?
Asked
Active
Viewed 218 times
0
-
The whole point of running a program in Docker is that you can't. – David Maze Mar 28 '22 at 18:32
1 Answers
0
I ran this on Ubuntu 20.04, but should be more or less the same on all UNIX boxes... you will need to either mount a local dir to your container or use volume. That way, a particular local dir where you have your local script will be mounted to the folder within your container
Start your container using -v
option
docker run -d -v /home/rootuser/LocalMcScriptFolder:/app/ContainerFolder YOURIMAGE
Go into your container, go to the folder and run the script
docker exec -it CONTAINERID bash
$cd ContainerFolder
$pwd
/app/ContainerFolder
$./test.sh