Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从主机上的docker容器运行Shellscript_Shell_Docker - Fatal编程技术网

如何从主机上的docker容器运行Shellscript

如何从主机上的docker容器运行Shellscript,shell,docker,Shell,Docker,我对shell脚本和docker领域还不熟悉。我正在尝试在docker容器中运行shell脚本来托管 一旦我的docker容器中的脚本执行完毕,我想在新终端中从主机运行另一个脚本,而不退出我的docker容器 我写过: exit 0 > $? if [ $? -eq 0 ]; then echo $? gnome-terminal --tab -x ./org3Added.sh fi 但这不起作用。Docker容器是一个沙箱。通常,您不能直接从将在主机上执行的容器内部运行脚本。理想的

我对shell脚本和docker领域还不熟悉。我正在尝试在docker容器中运行shell脚本来托管

一旦我的docker容器中的脚本执行完毕,我想在新终端中从主机运行另一个脚本,而不退出我的docker容器

我写过:

exit 0 > $?
if [ $? -eq 0 ]; then
echo $?
gnome-terminal --tab -x ./org3Added.sh
fi 


但这不起作用。

Docker容器是一个沙箱。通常,您不能直接从将在主机上执行的容器内部运行脚本。理想的方法是将主机视为远程机器,将ssh连接到其中并执行脚本

但是,您可以使用


您可以使用卷将目录装载到docker容器(docs:),在docker容器中运行脚本后,使其在文件系统中创建一个文件。在主机上,您可以观察挂载的目录,以确定何时出现此文件,并触发要使用的主机脚本(灵感:),我不太清楚您试图实现什么。容器是否做了一些工作并生成主机在您试图调用的脚本中使用的输出?基本上,我尝试在一个终端上运行脚本,该终端将连接我的网络,一旦我们的网络连接起来,而不关闭该终端,我必须打开一个新的终端,该终端将运行一个新的shell脚本(在该shell脚本中,我正在docker容器中复制一个shell脚本,一旦我执行了“docker exec-it cli bash-rcfile/opt/script.sh”,就会执行该脚本)一旦docker中的这个shell脚本被执行,我将在新终端上运行一个新脚本,再次启动一个新的docker容器,并在该docker容器中运行一个新脚本。希望这次我能够正确地解释我自己:)
--privileged: Give extended privileges to this container