diff --git a/libnetwork/pasta/pasta_linux.go b/libnetwork/pasta/pasta_linux.go index 33fbc35e6..45c4a5a20 100644 --- a/libnetwork/pasta/pasta_linux.go +++ b/libnetwork/pasta/pasta_linux.go @@ -36,6 +36,8 @@ const ( // mapGuestAddrIpv4 static ip used as forwarder address inside the netns to reach the host, // given this is a "link local" ip it should be very unlikely that it causes conflicts mapGuestAddrIpv4 = "169.254.1.2" + + mapHostLoopbackOpt = "--map-host-loopback" ) type SetupOptions struct { @@ -276,5 +278,18 @@ func createPastaArgs(opts *SetupOptions) ([]string, []string, []string, error) { mapGuestAddrIPs = append(mapGuestAddrIPs, mapGuestAddrIpv4) } + // outbound counterpart: without this the /etc/hosts entry podman writes for + // host.containers.internal is unreachable from bridge containers + hasMapHostLoopback := false + for _, opt := range cmdArgs { + if opt == mapHostLoopbackOpt { + hasMapHostLoopback = true + break + } + } + if !hasMapHostLoopback { + cmdArgs = append(cmdArgs, mapHostLoopbackOpt, mapGuestAddrIpv4) + } + return cmdArgs, dnsForwardIPs, mapGuestAddrIPs, nil }