From 4da1c11db9be415a0d218f2a1b94afb1d58fac8e Mon Sep 17 00:00:00 2001 From: Ramon Roche Date: Tue, 7 Apr 2026 17:29:57 -0700 Subject: [PATCH] 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 --- Tools/packaging/px4-entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tools/packaging/px4-entrypoint.sh b/Tools/packaging/px4-entrypoint.sh index 7c3ccf9fd2..a1d9b6c1f8 100644 --- a/Tools/packaging/px4-entrypoint.sh +++ b/Tools/packaging/px4-entrypoint.sh @@ -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"