MCPcopy
hub / github.com/docker/compose / isOrphaned

Function isOrphaned

pkg/compose/containers.go:146–158  ·  view source on GitHub ↗

isOrphaned is a predicate to select containers without a matching service definition in compose project

(project *types.Project)

Source from the content-addressed store, hash-verified

144
145// isOrphaned is a predicate to select containers without a matching service definition in compose project
146func isOrphaned(project *types.Project) containerPredicate {
147 services := append(project.ServiceNames(), project.DisabledServiceNames()...)
148 return func(c container.Summary) bool {
149 // One-off container
150 v, ok := c.Labels[api.OneoffLabel]
151 if ok && v == "True" {
152 return c.State == container.StateExited || c.State == container.StateDead
153 }
154 // Service that is not defined in the compose model
155 service := c.Labels[api.ServiceLabel]
156 return !slices.Contains(services, service)
157 }
158}
159
160func isNotOneOff(c container.Summary) bool {
161 v, ok := c.Labels[api.OneoffLabel]

Callers 2

downMethod · 0.85
collectObservedStateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected