Search code examples
dockerdocker-composemediasoup

Mediasoup error when running ObserveRTC example: `getaddrinfo ENOTFOUND host.docker.internal`


This is the project I want to setup: https://github.com/ObserveRTC/full-stack-examples

I started the app using this command:

SFU_ANNOUNCED_IP="192.168.60.79" docker-compose up

And this error happened at MediaSoup:

ObserveRTC::RestTransport Wed, 14 Dec 2022 07:44:56 GMT Request failed. canRetry: true Error: getaddrinfo ENOTFOUND host.docker.internal
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'host.docker.internal'
}

I found this IP from ifconfig:

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.60.79  netmask 255.255.255.0  broadcast 192.168.60.255
...

Solution

  • host.docker.internal parameter in Docker Compose file only defined in Windows and Mac which resolves to the internal IP address used by the host

    But my OS was Linux!

    In linux Use localhost in host mode or 172.18.0.1 for bridge mode.