方法
docker run に --add-host=host.docker.internal:host-gateway オプションを付ける。
例
docker run -it --add-host=host.docker.internal:host-gateway python bash
コンテナ内にて、cat /etc/hosts で host.docker.internal が追加されていることが分かる。
cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.65.2 host.docker.internal
172.17.0.3 c755951ee0f1