.net 在Visual Studio 2017中显示多个docker容器的交互式控制台
我目前正在开发一个带有多个docker容器的.Net核心项目,其中两个是.Net核心控制台应用程序,第三个是RabbitMQ 我的目标是打开一个控制台窗口,在该窗口中,我可以为docker容器中运行的至少一个控制台应用程序按enter键。 我通过右键单击我的控制台应用程序并单击“Add=>docker support”添加了docker支持 这是我的docker撰写文件:.net 在Visual Studio 2017中显示多个docker容器的交互式控制台,.net,docker,visual-studio-2017,.net,Docker,Visual Studio 2017,我目前正在开发一个带有多个docker容器的.Net核心项目,其中两个是.Net核心控制台应用程序,第三个是RabbitMQ 我的目标是打开一个控制台窗口,在该窗口中,我可以为docker容器中运行的至少一个控制台应用程序按enter键。 我通过右键单击我的控制台应用程序并单击“Add=>docker support”添加了docker支持 这是我的docker撰写文件: version: '3' services: service1: image: service1 bui
version: '3'
services:
service1:
image: service1
build:
context: ./Service1
dockerfile: Dockerfile
links:
- "rabbitmq:rabbit"
service2:
image: service2
build:
context: ./Service2
dockerfile: Dockerfile
links:
- "rabbitmq:rabbit"
rabbitmq:
image: "rabbitmq:3-management"
ports:
- "8082:15672"
- "5672:5672"
这是我的docker-compose-override.yml:
版本:“3”
但Visual Studio在运行Service2容器时会执行以下重写:
Service2:
build:
args:
source: obj/Docker/empty/
context: C:\Develop\vsts_tfs\Service2
dockerfile: Dockerfile
entrypoint: tail -f /dev/null
environment:
NUGET_FALLBACK_PACKAGES: /root/.nuget/fallbackpackages
image: service2:dev
labels:
com.microsoft.visualstudio.debuggee.arguments: ' --additionalProbingPath /root/.nuget/packages
--additionalProbingPath /root/.nuget/fallbackpackages bin/Debug/netcoreapp2.0/Service2.dll'
com.microsoft.visualstudio.debuggee.killprogram: /bin/bash -c "if PID=$(pidof
-x dotnet); then kill $PID; fi"
com.microsoft.visualstudio.debuggee.program: dotnet
com.microsoft.visualstudio.debuggee.workingdirectory: /app
links:
- rabbitmq:rabbit
volumes:
- C:\Develop\vsts_tfs\Service2:/app:rw
- C:\Users\MYUSER\vsdbg:/remote_debugger:ro
- C:\Program Files\dotnet\sdk\NuGetFallbackFolder:/root/.nuget/fallbackpackages:ro
- C:\Users\MYUSER\.nuget\packages:/root/.nuget/packages:ro
我的Service2需要一些控制台输入,所以我需要在交互式控制台中按“enter”。不幸的是,我没有打开任何控制台窗口——但我在调试窗口中看到Service2的输出告诉我按enter键——我就是不能按enter键
关于,对于C++项目,调试菜单中有一个所谓的“Linux控制台”——但我没有这个按钮。我还试图通过安装“VisualC++开发Linux”——功能,但没有帮助。
以下是我的调试菜单的外观:
你知道如何打开控制台窗口来控制docker容器中的应用程序吗
正如旁注:等待enter的应用程序仅用于开发目的,因为它向RabbitMQ管道发送命令而不使用web前端。可以在docker之外启动此功能,但它会破坏“按一个按钮运行它们”(并且不设置多个启动项目)的舒适性,并且会将docker和非docker组件的混合添加到我的解决方案中。PS:现在使用注释作为答案,因为我需要格式化。 您需要对docker compose进行2次更改
version: '3'
services:
service1:
image: service1
build:
context: ./Service1
dockerfile: Dockerfile
links:
- "rabbitmq:rabbit"
service2:
image: service2
build:
context: ./Service2
dockerfile: Dockerfile
links:
- "rabbitmq:rabbit"
stdin_open: true
tty: true
rabbitmq:
image: "rabbitmq:3-management"
ports:
- "8082:15672"
- "5672:5672"
现在,docker compose
不支持从stdin获取输入并将其传递到容器,因此无法从调试控制台继续会话。您需要运行另一个终端并运行
docker attach <foldername>_service2_1
docker连接服务2\u 1
基本上,您需要给出容器的名称或id。然后按enter键,容器将继续在这种情况下,哪个服务正在等待输入<代码>服务1或
服务2
?它是服务2。我还尝试在docker compose文件中将Service1与Service2交换,但没有成功。@Compufreak您找到解决方案了吗?我遇到了同样的问题。不幸的是,我记不起3年前我是如何解决这个问题的,我再也找不到这个项目了。我可能没有找到解决方案,否则我应该把它作为一个回应发布在这里。很抱歉感谢您的回答,不幸的是,它似乎无法与Visual Studio调试器协同工作,因为它将入口点:tail-f/dev/null
放入docker compose文件,并通过向docker容器中注入某种命令来启动进程,因此docker attach可能会抓住尾部-f/dev/null而不是我的应用程序:/能否在问题中也发布覆盖yml?my override.yml只包含版本:3
,我想您是在要求Visual Studio使用的一个。我将Visual Studio的Docker输出添加到我的问题中,它应该包含您要求的内容。这将使问题变得更加复杂,看起来很有希望,但遗憾的是,我遇到了与@Compufreak相同的问题。我无法连接到Visual Studio启动的.Net核心控制台容器。