Can I get ip address inside my docker 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).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)