fix(packaging): resolve host.docker.internal as IPv4 in SIH entrypoint

The SIH container entrypoint resolves host.docker.internal via getent
hosts and feeds the first result to mavlink -t and uxrce_dds_client -h.
On Docker Desktop for Windows the lookup can return an IPv6 ULA first,
and both PX4 modules only parse IPv4, so they error out with
'invalid partner ip' and PX4 boots with no working MAVLink or DDS link.

Switch to getent ahostsv4, which only returns IPv4 records, so the IP
injected into the startup scripts is always parseable.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
Ramon Roche
2026-04-07 17:29:57 -07:00
parent e4d46f20f4
commit 4da1c11db9
+5 -2
View File
@@ -17,9 +17,12 @@ else
PX4_PREFIX=/opt/px4
fi
if getent hosts host.docker.internal >/dev/null 2>&1; then
DOCKER_HOST_IP=$(getent hosts host.docker.internal | awk '{print $1}')
# Resolve host.docker.internal to an IPv4 address. mavlink and uxrce_dds_client
# only parse IPv4, and on Docker Desktop for Windows the default `getent hosts`
# lookup can return an IPv6 ULA first, which both modules then reject.
DOCKER_HOST_IP=$(getent ahostsv4 host.docker.internal 2>/dev/null | awk '/STREAM/ {print $1; exit}')
if [ -n "$DOCKER_HOST_IP" ]; then
# MAVLink: replace default target (127.0.0.1) with the Docker host IP
sed -i "s/mavlink start -x -u/mavlink start -x -t $DOCKER_HOST_IP -u/g" \
"$PX4_PREFIX/etc/init.d-posix/px4-rc.mavlink"