0

I have a Dockerfile that builds an image containing a custom console application:

FROM ubuntu:bionic

# Some non-relevant steps...

CMD  bin/my-console-app

my-console-app is a simple console app that, while it runs, it normally gives you the possibility of inserting commands.

For example

./my-console-app
my-console> some-command
Some result
my-console> some-other-command
Some other result

if I run the container that I've build using the above Dockerfile using -d, everything is fine:

docker run --name my-app --network host -d myapp

using the network I can see that the console app is correctly running.

However if I run it without -d, like:

docker run --name my-app --network host myapp

then my terminal will go crazy, like someone is constantly pressing ENTER:

my-console> 
my-console> 
my-console> 
my-console> 
my-console> 
my-console> 
my-console> 
my-console>
...

and this goes on forever. I cannot insert any command to my console app.

Why is that happening? What should I do to prevent this?

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252

1 Answers1

1

I solved my issue by passing -it to the docker run command.

So now I run my container using:

docker run --name my-app --network host -it myapp

EDIT: if using docker-compose, to solve this problem specify those 2 options for the service:

stdin_open: true
tty: true

thanks @user268396

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
  • 1
    `docker-compose` is not really meant for this use case. But see also: https://stackoverflow.com/questions/36249744/interactive-shell-using-docker-compose – user268396 Jan 16 '19 at 18:15