container_rename.go 411 B

1234567891011121314151617
  1. package client
  2. import (
  3. "net/url"
  4. "golang.org/x/net/context"
  5. )
  6. // ContainerRename changes the name of a given container.
  7. func (cli *Client) ContainerRename(ctx context.Context, containerID, newContainerName string) error {
  8. query := url.Values{}
  9. query.Set("name", newContainerName)
  10. resp, err := cli.post(ctx, "/containers/"+containerID+"/rename", query, nil, nil)
  11. ensureReaderClosed(resp)
  12. return err
  13. }