How to get container ip address inside this container?
'docker inspect $hostname ...' not suitable, because I don't share /var/run/docker.sock host file to container.
I can find the IP address with
hostname -i
Of course, that may not be completely accurate if there is more than one interface.
Edit
Note: According to the hostname man page, hostname -i
uses DNS to resolve the ip address, where hostname -I
displays all the addresses except loopback, does not depend on DNS, and is recommended.
In all my Docker containers, -i
and -I
return the same results (but this is not the case on my desktop).