healthcheck icon indicating copy to clipboard operation
healthcheck copied to clipboard

Healthcheck fail when container has multiple networks

Open Emptyfruit opened this issue 3 years ago • 1 comments

When container is in multiple networks, most of the healthchecks fail. The reason is that commands like

host="$(hostname -i || echo '127.0.0.1')"

(from postgres, redis), and

host="$(hostname --ip-address || echo '127.0.0.1')"

(from elasticsearch)

use hostname -i which in case of multiple networks return multiple ips. i.e.

[root@ccaa85c77ed1 elasticsearch]# hostname --ip-address
192.168.208.3 192.168.176.2

so $host becomes invalid.

Emptyfruit avatar Mar 23 '21 07:03 Emptyfruit

Fair point! We should probably improve that by limiting to just the first IP.

However, it is also worth noting that issues like this are why these are prototypes intended to be examples, not deployed as-is (because taking the first IP is a reasonable "general solution" to this, but for many users there are probably more use-case specific solutions that ought to be employed, such as checking all IPs or choosing a particular subnet instead of relying on ordering).

tianon avatar Mar 23 '21 18:03 tianon