I'm aware that you can get a host's ip programatically with Python doing something like:
from socket import gethostname, gethostbyname
ip = gethostbyname(gethostname())
print(ip)
but, as expected, when running the code mentioned above from a container (just ftr, with user namespaces enabled) the output is 172.17.0.2.
How can I programmatically get the host's ip from within the container?
Note: I'm working in a Linux environment.
This works on my mac
ip = gethostbyname('docker.for.mac.localhost')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With