0

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?

BasicUser
  • 58
  • 7

1 Answers1

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
Dharman
  • 26,923
  • 21
  • 73
  • 125
Redox
  • 1,240
  • 1
  • 4
  • 13