From 5d164bbefdfbdc791f676d483e45d06b3e77eefd Mon Sep 17 00:00:00 2001 From: David Steele Date: Sat, 10 Jan 2026 19:13:55 +0700 Subject: [PATCH] Use more generic expression to fetch container IP addresses. The IP address has been moved in newer versions of Docker but this expression will fetch the IP address from the old or new location. (cherry picked from commit 2b6a1de295160ddb016a7d65c8f5c08ff408b02c) --- doc/lib/pgBackRestDoc/Common/Host.pm | 5 ++++- test/src/common/harnessHost.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/lib/pgBackRestDoc/Common/Host.pm b/doc/lib/pgBackRestDoc/Common/Host.pm index 20606976b2..b70fc07d42 100644 --- a/doc/lib/pgBackRestDoc/Common/Host.pm +++ b/doc/lib/pgBackRestDoc/Common/Host.pm @@ -67,7 +67,10 @@ sub new {bSuppressStdErr => true}); # Get IP Address - $self->{strIP} = trim(executeTest("docker inspect --format '\{\{ .NetworkSettings.IPAddress \}\}' $self->{strContainer}")); + $self->{strIP} = trim( + executeTest( + "docker inspect --format '\{\{range .NetworkSettings.Networks\}\}\{\{.IPAddress\}\}\{\{end\}\}'" . + " $self->{strContainer}")); $self->{bActive} = true; # Return from function and log return values if any diff --git a/test/src/common/harnessHost.c b/test/src/common/harnessHost.c index 06aa52a5e9..7ab9bd0173 100644 --- a/test/src/common/harnessHost.c +++ b/test/src/common/harnessHost.c @@ -186,7 +186,10 @@ hrnHostNew(const StringId id, const String *const container, const String *const // Get IP address const String *const ip = strTrim( - execOneP(strNewFmt("docker inspect --format '{{ .NetworkSettings.IPAddress }}' %s", strZ(hrnHostContainer(this))))); + execOneP( + strNewFmt( + "docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' %s", + strZ(hrnHostContainer(this))))); MEM_CONTEXT_PRIOR_BEGIN() {