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

Method execRemoveContainer

pkg/compose/executor_ops.go:136–154  ·  pkg/compose/executor_ops.go::planExecutor.execRemoveContainer
(ctx context.Context, op Operation)

Source from the content-addressed store, hash-verified

134}
135
136func (exec *planExecutor) execRemoveContainer(ctx context.Context, op Operation) error {
137 _, err := exec.compose.apiClient().ContainerRemove(ctx, op.Container.ID, client.ContainerRemoveOptions{Force: true})
138 if err != nil {
139 return err
140 }
141 // Why: a dependent service's create may resolve `network_mode: service:X`
142 // (or volumes_from / ipc / pid) against the live view. Containers.sorted()
143 // orders by canonical name; without this drop, a just-removed container
144 // can still win the lookup and the dependent receives a container:<id>
145 // reference that no longer exists in the daemon.
146 svcName := op.Container.Labels[api.ServiceLabel]
147 exec.containersMu.Lock()
148 exec.containersByService[svcName] = slices.DeleteFunc(
149 exec.containersByService[svcName],
150 func(c container.Summary) bool { return c.ID == op.Container.ID },
151 )
152 exec.containersMu.Unlock()
153 return nil
154}
155
156func (exec *planExecutor) execRenameContainer(ctx context.Context, node *PlanNode) error {
157 op := node.Operation

Callers 1

executeNodeMethod · 0.95

Calls 3

apiClientMethod · 0.80
ContainerRemoveMethod · 0.45
LockMethod · 0.45

Tested by

no test coverage detected