container_remove.go 628 B

123456789101112131415161718192021222324252627
  1. package client // import "github.com/docker/docker/client"
  2. import (
  3. "context"
  4. "net/url"
  5. "github.com/docker/docker/api/types/container"
  6. )
  7. // ContainerRemove kills and removes a container from the docker host.
  8. func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error {
  9. query := url.Values{}
  10. if options.RemoveVolumes {
  11. query.Set("v", "1")
  12. }
  13. if options.RemoveLinks {
  14. query.Set("link", "1")
  15. }
  16. if options.Force {
  17. query.Set("force", "1")
  18. }
  19. resp, err := cli.delete(ctx, "/containers/"+containerID, query, nil)
  20. defer ensureReaderClosed(resp)
  21. return err
  22. }