简体   繁体   English

启动运行Mono控制台应用程序的Docker容器的bash脚本无法以交互方式发送命令

[英]bash script to start a docker container running a mono console application cannot send commands in interactive mode

Assuming the container name is "dave" and the mono application is called "dummy_app" 假设容器名称为“ dave”,而单声道应用程序称为“ dummy_app”

dockerfile for the container: 容器的dockerfile:

FROM mono:latest
ADD . /src
EXPOSE 8081
RUN xbuild /src/dummy_app.sln
CMD [ "mono", "/src/dummy_app/bin/Debug/dummy_app.exe" ]

script: 脚本:

echo "Start"
sudo docker start -i dave
echo "debug true"

The script stalls at the line "sudo docker start -i dave" because I assume it waits to detach from the stdin of the container in order to continue. 该脚本停在“ sudo docker start -i dave”行,因为我认为它等待与容器的stdin分离以便继续。 Hence line "debug true" does not execute. 因此,“ debug true”行不会执行。

In the ssh session I can see the container starting up launching the mono application and I can type commands in and get responses as with a normal console application but I can't figure out how to send commands from the script into the newly attached container that would achieve the same thing. 在ssh会话中,我可以看到容器开始启动mono应用程序,并且可以像普通控制台应用程序一样键入命令并获取响应,但是我不知道如何将命令从脚本发送到新连接的容器中会达到相同的目的。

From here 这里

Start one or more containers

  -a, --attach=false         Attach STDOUT/STDERR and forward signals
  --help=false               Print usage
  -i, --interactive=false    Attach container's STDIN

You need to remove the -i flag. 您需要删除-i标志。

In general for all the docker commands you can use the --help flag to check the options you have and the default values. 通常,对于所有docker命令,您都可以使用--help标志来检查您拥有的选项和默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM