Reputation: 4639
I am currently developing a .Net Core-project with multiple docker containers, 2 are .NET Core Console Applications, the third is RabbitMQ.
My target is to open a console window where I can press enter for at least one of the console applications running in the docker containers.
I added docker-support by right-clicking my console applications and clicking "Add => Docker Support".
This is my docker-compose-file:
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"
This is my docker-compose-override.yml:
version: '3'
But Visual Studio does the following overrides when running the Service2-container:
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
My Service2 needs to get some console input, so I need to press "enter" in an interactive console. Unfortunately I don't get any console window to open - but I see the output of my Service2 in the Debug-Window telling me to press enter - I just can't press enter.
Regarding to this question, for C++-projects there is a so called "Linux Console" in the Debug-Menu - but I don't have this button. I also tried to get it by installing the "Visual C++ for Linux-Development"-Feature, but it didn't help.
This is how my Debug-Menu looks like:
Any ideas how I can open a console window to control the application inside my docker-container?
Just as a side note: The application waiting for enter is just for development purposes, as it sends commands to the RabbitMQ-pipeline without the usage of the web-frontend. It would be possible to start this outside of docker, but it would destroy the comfort of "running them all by pressing one button" (and without setting multiple startup projects) and would add a mixture of docker- and non-docker-components to my solution.
Upvotes: 3
Views: 1124
Reputation: 146630
PS: Using comments as answer for now since I need formatting
You need make 2 changes to your docker-compose
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"
Now docker-compose
doesn't support taking input from stdin and passing it to the container, so there is no way you can continue the session from debug console. You need to run another terminal and run
docker attach <foldername>_service2_1
Basically you need to give the name or id of the container. Then you press enter the container will continue further
Upvotes: 3