docker/compose

docker-compose up interactive mode

MitchK opened this issue ยท 5 comments

I have this in my Dockerfile:

...
CMD bash on-start.sh

I can run it using this and I get an interactive shell as desired.

$ docker run -it imagename
$ _

But it does not work when doing this:

$ docker-compose up
...
exited with code 0

If I do this, it works as well, but dependent services are not started.

$ docker-compose run myservice 
$ _

My versions:

$ docker --version
Docker version 1.10.0, build 590d5108
$ docker-compose --version
docker-compose version 1.6.0, build d99cad6

You probably want to use stdin_open: true in your Compose file.

That is expected behaviour. up is not interactive. It can start multiple containers, so you can't have a single terminal that has stdin open for multiple containers.

run should do what you want. If you use depends_on it will start dependencies as of Compose 1.6.2 (the bug was fixed in compose 1.6.1), so you'll need to upgrade as well.

@dnephin
Daniel, I have to thank you for your note on this topic. I've been struggling for two days to get a container to function in an interactive mode on a Node server where I also need to input some data via the terminal on the back end. The wording of your note got me to look at my issue from a different direction. A long slow read of the docker compose details (including the run method) really worked for me. Many thanks.

I wanted to get interactive access to the Python debugger pdb running in a docker-compose environment. TIL I can do that with docker attach myservice

bam80 commented

That is expected behaviour. up is not interactive.

@dnephin
Daniel, I have to thank you for your note on this topic. I've been struggling for two days to get a container to function in an interactive mode on a Node server where I also need to input some data via the terminal on the back end.

@dnephin
That probably should be pointed out in the documentation explicitly.
I've been struggled for two days or so too, without obvious reason why it doesn't work, until I faced the question on SO suddenly:
https://stackoverflow.com/questions/53106678/docker-compose-up-and-user-inputs-on-stdin

And also, podman-compose up (which I used for actual composing) does work in interactive mode which makes things even more confusing..

PS:

You probably want to use stdin_open: true in your Compose file.

That didn't help to the problem.