Run shell script inside Docker container from another Docker container?

时光总嘲笑我的痴心妄想 提交于 2021-01-28 08:12:00

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/42352104/run-shell-script-inside-docker-container-from-another-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!