1

I am using docker-compose with:

  1. an existing (python) app running inside a docker container.
  2. another (ruby) command-line app running in a docker container.

How do I 'connect' those two containers so that the python container can call the command-line app in the ruby container? (and pass arguments via stdin/stdout)

9
  • Maybe you could make a volume to share the Ruby command-line app and mount this volume in the Python container Commented Oct 27, 2016 at 13:54
  • I can share a volume, but how do I run the command inside the other container? Commented Oct 27, 2016 at 14:00
  • @gingerlime, are the two container running currently and you want to run the a command in one of the container? Commented Oct 27, 2016 at 14:08
  • 1
    maybe something like docker exec <container> <command>. or docker exec -it <container> <command> if you want to get the terminal from the container to see what happens Commented Oct 27, 2016 at 14:08
  • 1
    You should update your question with details from the comments and add any other important detail. Potential answers will be better. Commented Oct 27, 2016 at 14:21

1 Answer 1

2

Options are available, but not great. If you're using a recent version of Docker Compose then both containers will be in the same Docker network and can communicate, so you could install sshd in the destination container and make ssh calls from the source container.

Alternatively, use Docker in Docker with the source container, so you can run docker exec inside the source and execute commands on the target container.

It's low-level communication though, and raising it to a service call or message passing would be better, if changing your apps is feasible.

Sign up to request clarification or add additional context in comments.

1 Comment

I was hoping to avoid SSH, since it's considered bad practice AFAIK. I'll take a look at Docker-in-Docker, but I'm using a pre-built image so not sure how to 'convert' it to use DiD ... Indeed not great. With all the talks about best-practice of running only one thing in a container, I would have thought this kind of use-case will be somehow straight-forward...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.