This is a known limitation and not exactly clear when reading over docs. You have to find opaque references here and there:
- https://docs.docker.com/docker-for-mac/faqs/#how-do-i-connect-from-a-container-to-a-service-on-the-host
- Access host (not vm) from inside container
TL;DR you have to create an alias on your loop back to a non-routable IP of your choosing, say a 172.16.x.x that doesn’t conflict.
sudo ifconfig lo0 alias 172.16.1.1
Then you access your host inside containers with 172.16.1.1 for example.