On Mac and Windows it is possible to use docker.for.mac.host.internal (replaces docker.for.mac.localhost) and docker.for.win.host.int
docker.for.mac.host.internal
docker.for.mac.localhost
docker.for.win.host.int
Depends what you're trying to do. If you're running with --net=host, localhost should work fine. If you're using default networking, use the static IP 172.17.0.1. I suspect neither will behave quite the same as those domains.
--net=host
localhost
172.17.0.1