Skip to content

Commit 3421f21

Browse files
committed
dockerdiscovery: discover containers from host network
1 parent 1975f5e commit 3421f21

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

pkg/erdiscovery/dockerdiscovery/docker.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"fmt"
77
"log"
8+
"log/slog"
89
"net"
910
"net/http"
1011
"os"
@@ -272,6 +273,15 @@ func discoverDockerContainers(
272273
ipAddress = settings.IPAddress // fall back to bridge IP if not found
273274
}
274275

276+
if settings, found := container.NetworkSettings.Networks["host"]; !ipFound() && found {
277+
// when host network, settings doesn't specify IP address
278+
if settings.IPAddress != "" {
279+
slog.Warn("IPAddress not expected for host", "container", container.Id)
280+
continue
281+
}
282+
ipAddress = "127.0.0.1"
283+
}
284+
275285
// if container is attached to e.g. an overlay network, but Edgerouter sits e.g. in the host
276286
// network namespace (= no direct connectivity to the overlay network), our last-ditch effort
277287
// is to resolve its docker_gwbridge IP, but it is not visible from "$ docker inspect" output,

0 commit comments

Comments
 (0)