I have a websocket server running locally on port 3000. This websocket server is NOT dockerized. I also have a websocket client (myclient) which IS dockerized. The myclient is communicating with another dockerized microservice (anothermicroservice) via named bridge network (mybridgenet). I would like the myclient to connect to the websocket server, which as mentioned is not dockerized and it is running at 127.0.0.1:3000. Since 127.0.0.1 for the myclient is the container's address I cannot simply use it as such. My question is, How do I keep the communication between myclient and anothermicroservice via the bridge network, and at the same connect the myclient to the non-dockerized websocket server at the localhost 127.0.0.1:3000?
I tried to use the network_mode host option but it cannot work together with networks
My docker-compose file is as following:
version: '3.7'
services:
myclient:
container_name:
myclient
hostname:
myclient
build:
context:
.
dockerfile:
Dockerfile
depends_on:
- anothermicroservice
env_file:
- server.env # within this file I have the server uri 127.0.0.1:3000
networks:
- mybridgenet
anothermicroservice:
container_name:
anothermicroservice
hostname:
anothermicroservice
build:
context:
../anothermicroservice
dockerfile:
Dockerfile
networks:
- mybridgenet
networks:
mybridgenet:
name:
mybridgenet
driver:
bridge