Client (netcore console) cannot reach socket server (aspnet core) when both client and server are running in a docker container

We have a socketserver that also exposes a webapi method. When that method is called, it sends the result also to the (socket)clients.

The server ( core) is running on localhost:8888, the client (console .netcore app) connects by ws://localhost:8888/connecttosocketserver/to/ws

This works well when running the code locally.
This works also when running the serversocket in a dockercontainer and the client locally.

This doesn’t work when running both the client and serversocket in
a dockercontainer

The docker commands I’ve used:

docker run -it --rm -p 8888:80 server-image
docker run -it --rm client-image

I’ve tried to get this working by using a docker network, to let the containers communicate with eachother without any luck.

Here I’ve found a possible solution. But I didn’t find a way to listen to all IP Addresses with the websocketmiddleware I’ve implemented.

Any idea’s on how to let the client communicate with the socketserver when both, client and server are running in a docker container?

Source: StackOverflow