Skip to content

Modern Docker Management, Designed for Everyone

fix: exclude swarm task containers from the standalone filter (#4405)

Kyle Mendell0c052dd6784f
diff --git a/backend/internal/container/service.go b/backend/internal/container/service.go
index b8aaab6db..be754e51c 100644
--- a/backend/internal/container/service.go
+++ b/backend/internal/container/service.go
@@ -2126,7 +2126,7 @@ func (s *ContainerService) buildContainerFilterAccessors() []pagination.FilterAc
{
Key: "standalone",
Fn: func(c containertypes.Summary, filterValue string) bool {
- isStandalone := docker.ComposeProjectLabel(c.Labels) == ""
+ isStandalone := docker.ComposeProjectLabel(c.Labels) == "" && !labels.IsSwarmTask(c.Labels)
value, valid := kit.ParseBool(filterValue)
return !valid || isStandalone == value
},
diff --git a/backend/internal/container/service_test.go b/backend/internal/container/service_test.go
index 72936de6b..580be1884 100644
--- a/backend/internal/container/service_test.go
+++ b/backend/internal/container/service_test.go
@@ -187,6 +187,7 @@ func TestBuildContainerFilterAccessors_FiltersStandaloneContainers(t *testing.T)
items := []containertypes.Summary{
{ID: "standalone", Labels: map[string]string{}, UpdateInfo: updateInfo},
{ID: "compose", Labels: map[string]string{"com.docker.compose.project": "alpha"}, UpdateInfo: updateInfo},
+ {ID: "swarm-task", Labels: map[string]string{"com.docker.swarm.service.name": "web"}, UpdateInfo: updateInfo},
}
result := pagination.Config[containertypes.Summary]{FilterAccessors: service.buildContainerFilterAccessors()}.SearchOrderAndPaginate(