简体   繁体   中英

How to run a command on a linked docker container?

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM