github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/client/container_remove.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "net/url" 6 7 "github.com/docker/docker/api/types" 8 ) 9 10 // ContainerRemove kills and removes a container from the docker host. 11 func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error { 12 query := url.Values{} 13 if options.RemoveVolumes { 14 query.Set("v", "1") 15 } 16 if options.RemoveLinks { 17 query.Set("link", "1") 18 } 19 20 if options.Force { 21 query.Set("force", "1") 22 } 23 24 resp, err := cli.delete(ctx, "/containers/"+containerID, query, nil) 25 defer ensureReaderClosed(resp) 26 return wrapResponseError(err, resp, "container", containerID) 27 }