container_remove.go 578 B

12345678910111213141516171819202122232425262728
  1. package client
  2. import (
  3. "net/url"
  4. "github.com/docker/engine-api/types"
  5. "golang.org/x/net/context"
  6. )
  7. // ContainerRemove kills and removes a container from the docker host.
  8. func (cli *Client) ContainerRemove(ctx context.Context, options types.ContainerRemoveOptions) 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/"+options.ContainerID, query, nil)
  20. ensureReaderClosed(resp)
  21. return err
  22. }