user1566200
user1566200

Reputation: 1838

Run shell script inside Docker container from another Docker container?

If I am on my host machine, I can kickoff a script inside a Docker container using:

docker exec my_container bash myscript.sh

However, let's say I want to run myscript.sh inside my_container from another container bob. If I run the command above while I'm in the shell of bob, it doesn't work (Docker isn't even installed in bob).

What's the best way to do this?

Upvotes: 2

Views: 918

Answers (1)

user2915097
user2915097

Reputation: 32216

Simply launch your container with something like

docker run -it -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker ...

and it should do the trick

Upvotes: 1

Related Questions