I want to run a simple dotnet core console app in a container interactively. I am not able to do that and the container simply starts and then exits immediately without fully ru
I found, Docker compose run is an alternative to up command.
docker-compose run <service name from docker-compose.yml file>
Specifically, for my application, the docker compose file looks as follows.
version: '3.4'
services:
dokconsoleapp:
image: ${DOCKER_REGISTRY-}dokconsoleapp
build:
context: .
dockerfile: DokConsoleApp/Dockerfile
# stdin_open: true
# tty: true
Note the last two lines are commented out.
Now if I run
docker-compose run dokconsoleapp
The container runs till the end of the program, interactively waiting for me to type an input after Hello-World!.
So statements
stdin_open: true
tty: true
are not needed when you use run with docker-compose instead of up
By default, you don't have an interactive TTY when the container is started with docker-compose up
.
You need to add that to your service:
stdin_open: true
tty: true