RemoveContainer removes the container.
( _ context.Context, r *v1.RemoveContainerRequest, )
| 28 | |
| 29 | // RemoveContainer removes the container. |
| 30 | func (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 | |
| 60 | func (ds *dockerService) getContainerCleanupInfo(containerID string) (*containerCleanupInfo, bool) { |
| 61 | ds.cleanupInfosLock.RLock() |
no test coverage detected