Is it possible for two separate Docker containers to communicate over a ZMQ IPC socket? If so, how can this be achieved?
For example:
Docker Container #1 executes an application that creates a ZMQ Response socket and binds to "ipc://tmp/service_name".
Docker Container #2 executes an application that creates a ZMQ Request socket and connects to "ipc://tmp/service_name".
The following commands are used to run the applications in two separate docker containers:
// Run container #1 (binds to "ipc://tmp/service_name")
docker run --name c1 -it container1
// Run container #2 (connects to "ipc://tmp/service_name")
docker run -it --link c1:container1 --name c2 container2
After running the containers, I am not able to establish the ZMQ (IPC) connection. However, I am able to ping container 1 from container 2, and ping container 2 from container 1.
I also tried using the --ipc command, but it did not help:
// Run container #1 (binds to "ipc://tmp/service_name")
docker run --name c1 --ipc=host -it container1
// Run container #2 (connects to "ipc://tmp/service_name")
docker run -it --link c1:container1 --ipc=container:c1 --name c2 container2
UPDATE: I am able to communicate between two separate Docker containers using a ZMQ TCP socket, but am still unable to communicate using an IPC socket. Is it possible?
Have you seen Shared Memory with Docker containers (docker version 1.4.1)? It sounds like you need to share the volume where the IPC lives and also set
--ipc host
. In your example, it would be something like: