How to reach localhost on host from docker container?

  extra_hosts:
    - "host.docker.internal:host-gateway"

Does work under Linux, if you don’t want to use the network mode host in Docker.

However, make sure you set: live-restore: false (it should false by default, but maybe you changed the /etc/docker/daemon.json file), otherwise host.docker.internal doesn’t seem to resolve anymore under Linux…

This this bug is still not fixed in a 20.10 release: Fixed docker.internal.gateway not displaying properly on live restore by sanchayanghosh · Pull Request #42785 · moby/moby · GitHub