MCPcopy Create free account
hub / github.com/Mirantis/cri-dockerd / RemoveContainer

Method RemoveContainer

core/container_remove.go:30–58  ·  view source on GitHub ↗

RemoveContainer removes the container.

(
	_ context.Context,
	r *v1.RemoveContainerRequest,
)

Source from the content-addressed store, hash-verified

28
29// RemoveContainer removes the container.
30func (ds *dockerService) RemoveContainer(
31 _ context.Context,
32 r *v1.RemoveContainerRequest,
33) (*v1.RemoveContainerResponse, error) {
34 // Ideally, log lifecycle should be independent of container lifecycle.
35 // However, docker will remove container log after container is removed,
36 // we can't prevent that now, so we also clean up the symlink here.
37 err := ds.removeContainerLogSymlink(r.ContainerId)
38 if err != nil {
39 return nil, err
40 }
41 errors := ds.performPlatformSpecificContainerForContainer(r.ContainerId)
42 if len(errors) != 0 {
43 return nil, fmt.Errorf(
44 "failed to run platform-specific clean ups for container %q: %v",
45 r.ContainerId,
46 errors,
47 )
48 }
49 err = ds.client.RemoveContainer(
50 r.ContainerId,
51 types.ContainerRemoveOptions{RemoveVolumes: true, Force: true},
52 )
53 if err != nil {
54 return nil, fmt.Errorf("failed to remove container %q: %v", r.ContainerId, err)
55 }
56
57 return &v1.RemoveContainerResponse{}, nil
58}
59
60func (ds *dockerService) getContainerCleanupInfo(containerID string) (*containerCleanupInfo, bool) {
61 ds.cleanupInfosLock.RLock()

Callers 1

RemovePodSandboxMethod · 0.95

Calls 4

lenFunction · 0.85
RemoveContainerMethod · 0.65

Tested by

no test coverage detected