volume_inspect.go 625 B

12345678910111213141516171819202122232425
  1. package client
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "github.com/docker/engine-api/types"
  6. "golang.org/x/net/context"
  7. )
  8. // VolumeInspect returns the information about a specific volume in the docker host.
  9. func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) {
  10. var volume types.Volume
  11. resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil)
  12. if err != nil {
  13. if resp.statusCode == http.StatusNotFound {
  14. return volume, volumeNotFoundError{volumeID}
  15. }
  16. return volume, err
  17. }
  18. err = json.NewDecoder(resp.body).Decode(&volume)
  19. ensureReaderClosed(resp)
  20. return volume, err
  21. }