From 91e7f4894a3940ecbf1dcde1413ad43eafe223de Mon Sep 17 00:00:00 2001 From: yusing Date: Sat, 28 Sep 2024 12:34:06 +0800 Subject: [PATCH] fixed some containers being excluded on restart --- internal/docker/container.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/docker/container.go b/internal/docker/container.go index 0e492e4..da6905b 100644 --- a/internal/docker/container.go +++ b/internal/docker/container.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/docker/docker/api/types" + "github.com/sirupsen/logrus" U "github.com/yusing/go-proxy/internal/utils" ) @@ -32,6 +33,9 @@ func FromDocker(c *types.Container, dockerHost string) (res Container) { StopSignal: res.getDeleteLabel(LabelStopSignal), Running: c.Status == "running" || c.State == "running", } + if res.NetworkMode == "" { + logrus.Debugf("%v", res.NetworkSettings.Networks) + } return } @@ -48,7 +52,7 @@ func FromJson(json types.ContainerJSON, dockerHost string) Container { }) } } - return FromDocker(&types.Container{ + cont := FromDocker(&types.Container{ ID: json.ID, Names: []string{json.Name}, Image: json.Image, @@ -57,6 +61,8 @@ func FromJson(json types.ContainerJSON, dockerHost string) Container { State: json.State.Status, Status: json.State.Status, }, dockerHost) + cont.NetworkMode = string(json.HostConfig.NetworkMode) + return cont } func (c Container) getDeleteLabel(label string) string {