How to make WebRTC works between Host and a service in the docker compose network?

Here is a diagram explaining the issue I am facing and trying to solve.

This prevents my browser to peer connect, through webRTC, to a service running in a docker container which belongs to the docker-compose default network.

enter image description here

Here is what I tried so far with no success:

  • Using STUN and a TURN servers
  • Using the extra_hosts option in docker compose for both containers with the following value: host.docker.internal:host-gateway

So my question is: why the iceConnection transitions from checking to disconnected states, and more importantly, how to solve this?

My assumption is that the WebRTCPeerconnection from the code running in the web browser fails to connect to the socket opened by the service running in the container because Host and Docker Compose project are not in the same network. I would have thought that the TURN middleman would solve this though, which is not the case apparently.