Closed LeifW closed 3 years ago
I'd rather not use hostname -i
since it is based on dns resolution of the hostname; even the man page recommends against using it. Unfortunately, --all-ip-addresses
is going to have the same issue as the current ip address
.
https://manpages.debian.org/buster/hostname/hostname.1.en.html#OPTIONS
-i, --ip-address
Display the network address(es) of the host name. Note that this
works only if the host name can be resolved. Avoid using this op‐
tion; use hostname --all-ip-addresses instead.
-I, --all-ip-addresses
Display all network addresses of the host. This option enumerates
all configured addresses on all network interfaces. The loopback
interface and IPv6 link-local addresses are omitted. Contrary to
option -i, this option does not depend on name resolution. Do not
make any assumptions about the order of the output.
I think it is valid for us to skip any link-local addresses (169.254.x.x
).
It works fine when the networking mode for the container is set to "host" on AWS ECS, but when the networking mode is set to "awsvpc", the _ip_address function in the docker-entrypoint.sh script produces a 169.154.xxx.xxx address (which isn't externally addressable and doesn't work).
If I replace invocations of that
_ip_address
function withhostname -i
, it works. I added echo lines for those two in thedocker-entrypoint.sh
and ran it on ECS w/ awsvpc networking mode:_ip_address
: 169.254.172.8hostname -i
: 10.0.0.212Here is the output of
ip address
from inside the container on ECS:Seems it would be simpler to just use
hostname -i
and get rid of that bash function?