Compose: docker-compose up interactive mode

Created on 5 Mar 2016  ·  4Comments  ·  Source: docker/compose

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
kinquestion

Most helpful comment

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

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings