I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST
The Mac has a changing IP address (or none if you have no network access). Our current recommendation is to attach an unused IP to the lo0 interface on the Mac; for example: sudo ifconfig lo0 alias 10.200.10.1/24, and make sure that your service is listening on this address or 0.0.0.0 (ie not 127.0.0.1). Then containers can connect to this address.
docker 在 windows 下和 Mac OS X 下网络不一样。
windows 下,network-mode=host 可以很方便解决
http://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach
解决 Mac OS X 下 docker 访问宿主机的方法。
https://docs.docker.com/docker-for-mac/networking/#known-limitations-use-cases-and-workarounds
I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST
The Mac has a changing IP address (or none if you have no network access). Our current recommendation is to attach an unused IP to the lo0 interface on the Mac; for example: sudo ifconfig lo0 alias 10.200.10.1/24, and make sure that your service is listening on this address or 0.0.0.0 (ie not 127.0.0.1). Then containers can connect to this address.
windows 下也可以用类似 Mac OS X 的方案启动服务
https://www.groovypost.com/howto/install-loopback-adapter-windows-8-server-2012/