Docker container not resolving to host

Trying to connect to the host machine from a docker container per the docker docs:

services:
  myService:
    extra_hosts:
      host.docker.internal: host-gateway

Inside the myService container, I’m using curl to try to connect to another service running on the host on port 8002:

> curl http://host.docker.internal:8002
curl: (7) Failed to connect to host.docker.internal port 8002: Connection timed out

What am I missing? Is this a bug?

2 Likes

I have the same issue. There must be a missing or conflicting firewall rule because it works if I stop the firewall. Docker’s firewall rules seems to be added but I’ve not spent the time to figure out what’s wrong and how to fix it.