On Docker for Mac what would be the host ip as see

2019-02-05 09:17发布

问题:

This question already has an answer here:

  • How to get the IP address of the docker host from inside a docker container 15 answers

I need to setup a debugger on my container, that requires me to set the remote (docker host) IP. In different tutorials I find different IP addresses listed as possible solution. In my container I ran a webserver that showed me that connections made to the container from my host machine come from 172.19.0.1. This is on Docker for Mac version 1.11.x.

But how would I reliably find out the host IP as seen from the container on Docker for Mac? When would it be possible for this IP to change?

Edit: Duplicate of https://stackoverflow.com/a/24716645/6309

回答1:

You can get the ip of the host from within the container by running this command:

/sbin/ip route|awk '/default/ { print $3 }'


标签: macos docker