2

Is there some software/framework/workaround that provide an easy way to exchange messages between the host and a container?

More specifically, I have a host running a Python server on Ubuntu. This host creates several containers running Node servers on an Ubuntu image. The host should send and receive messages to/from each container and they must not use the internet for this.

If there's no such software/framework, one possible workaround would be to write the messages to a file inside the container and the host reads them? Would it be possible to run several threads doing the same at the same time (each thread on a specific container)?

  • The question is not docker specific. It's just crossprocess communication and might be answered already years ago. And totally not at softwarerecs. – Nakilon May 14 at 7:13
  • Actually, being docker born because of a pretty recent feature (cgroups) and a lot of new softwares being built on top of docker's existence, I wondered if a dedicated communication tool between host and container wouldn't be existing by now. Also, given that docker creates it's own private networks for inter-communication, it's not a crazy idea to build some interface on top of them. – Teodoro May 15 at 0:28
0

Sockets on the local host are the most usual way of doing this sort of thing - the file option can hit problems unless: a) Each thread has its own file & b) all writes are flushed and event then you can hit buffering problems & race conditions.

I would suggest that you look into using the built-in Multiprocessing Library with Managers to handle the interaction and data exchange. If the IP Addresses are all ('', port) then traffic will be confined to the local machine. You will need a recent version of Python 3 and you will need to set up the appropriate port forwarding for your docker containers.

| improve this answer | |
  • 1
    The "Managers" hint will also help me in another project! Thanks, I think this is the right way. – Teodoro May 7 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.