info.go 570 B

123456789101112131415161718192021222324252627
  1. package client
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "net/url"
  6. "github.com/docker/engine-api/types"
  7. "golang.org/x/net/context"
  8. )
  9. // Info returns information about the docker server.
  10. func (cli *Client) Info(ctx context.Context) (types.Info, error) {
  11. var info types.Info
  12. serverResp, err := cli.get(ctx, "/info", url.Values{}, nil)
  13. if err != nil {
  14. return info, err
  15. }
  16. defer ensureReaderClosed(serverResp)
  17. if err := json.NewDecoder(serverResp.body).Decode(&info); err != nil {
  18. return info, fmt.Errorf("Error reading remote info: %v", err)
  19. }
  20. return info, nil
  21. }