From fa8ef5e15acd5601a186a8ffcb0604997b17ba0c Mon Sep 17 00:00:00 2001 From: nathants Date: Mon, 14 Dec 2020 17:22:22 -0800 Subject: [PATCH] network host should work (#171) --- .../app/master/inspectors/container/container_inspector.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/app/master/inspectors/container/container_inspector.go b/internal/app/master/inspectors/container/container_inspector.go index 0ab1b46669..f57d4fabbb 100644 --- a/internal/app/master/inspectors/container/container_inspector.go +++ b/internal/app/master/inspectors/container/container_inspector.go @@ -524,7 +524,9 @@ func (i *Inspector) RunContainer() error { } errutil.FailWhen(i.ContainerInfo.NetworkSettings == nil, "docker-slim: error => no network info") - errutil.FailWhen(len(i.ContainerInfo.NetworkSettings.Ports) < len(commsExposedPorts), "docker-slim: error => missing comms ports") + if containerOptions.HostConfig.NetworkMode != "host" { + errutil.FailWhen(len(i.ContainerInfo.NetworkSettings.Ports) < len(commsExposedPorts), "docker-slim: error => missing comms ports") + } i.logger.Debugf("RunContainer: container NetworkSettings.Ports => %#v", i.ContainerInfo.NetworkSettings.Ports) if len(i.ContainerInfo.NetworkSettings.Ports) > 2 { @@ -765,7 +767,7 @@ func (i *Inspector) initContainerChannels() error { var cmdPort string var evtPort string - if i.InContainer { + if i.InContainer || i.Overrides.Network == "host" { targetHost = i.ContainerInfo.NetworkSettings.IPAddress cmdPort = cmdPortStrDefault evtPort = evtPortStrDefault