Docker - Two containers on same network can't connect over web socket

1.3k Views Asked by At

Disclaimer

This is only happening on my machine. I tested the exact same code and procedure on my colleague's machine and it's working fine.

Problem

Hello, I have a fairly weird problem at hand.

I am running two Docker containers: One is a crossbar server instance, and the other is an application that uses WAMP (Web Application Messaging Protocol) and registers to the running crossbar server.
Nothing crazy

I run these two applications on two different docker containers that share the same network.

docker network create poc-bridge
docker run --net=poc-bridge -d --name cross my-crossbar-image
docker run --net=poc-bridge --name app my-app-image

Here is the dockerfile I used to build the image my-crossbar-image

FROM crossbario/crossbar

EXPOSE 8080

USER root
COPY deployment/crossbar/.crossbar /node/.crossbar

It simply exposes the port and copy some config files.

The other image for the app that needs to register to the crossbar server is not relevant.

Once I run my app in its container and it tries to register something to the crossbar server using the websocket address ws://cross:8080/ws I get:
OSError: [Errno 113] Connect call failed ('172.24.0.2', 8080)

What I tried

  • I checked that the two containers are actually on the same network (they are)
  • I could ping container cross from my container app with docker exec app ping cross -c2 (weird)

What can it be???

1

There are 1 best solutions below

0
giulio di zio On

The reason of the problem was not clear. However, it disappeared. All I had to do was:

  • Stopping/Removing all the created containers
  • Removing all the created images
  • Removing all the created networks
  • Re-building all again

Now the services can communicate to each other