container_update.go 668 B

123456789101112131415161718192021
  1. package client // import "github.com/docker/docker/client"
  2. import (
  3. "context"
  4. "encoding/json"
  5. "github.com/docker/docker/api/types/container"
  6. )
  7. // ContainerUpdate updates the resources of a container.
  8. func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) {
  9. var response container.ContainerUpdateOKBody
  10. serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
  11. defer ensureReaderClosed(serverResp)
  12. if err != nil {
  13. return response, err
  14. }
  15. err = json.NewDecoder(serverResp.body).Decode(&response)
  16. return response, err
  17. }