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
  • 108
  • 1
  • 8

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
  • 30,962
  • 25
  • 85
  • 135
Redox
  • 9,321
  • 5
  • 9
  • 26