6

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

Community
  • 1
  • 1
ddinchev
  • 33,683
  • 28
  • 88
  • 133
  • @VonC it is not a duplicate as this question concerns "Docker for Mac" which has some important difference in the archtecture – ciekawy Aug 04 '16 at 21:35
  • can you precise where is the listening service and where is the client initiating connection (on mac host or inside the container)? to connect from the container to mac host its enough to use the main mac host ip which is usually the `en0`. For the opposite direction looks like currently the only way is to use the usual docker port mapping like `-p 1234:1234` – ciekawy Aug 04 '16 at 21:46

1 Answers1

10

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

/sbin/ip route|awk '/default/ { print $3 }'
fotinakis
  • 7,792
  • 2
  • 26
  • 28
Kevin Simper
  • 1,669
  • 19
  • 32