version.go 490 B

12345678910111213141516171819202122
  1. package client
  2. import (
  3. "encoding/json"
  4. "github.com/docker/engine-api/types"
  5. "golang.org/x/net/context"
  6. )
  7. // ServerVersion returns information of the docker client and server host.
  8. func (cli *Client) ServerVersion(ctx context.Context) (types.Version, error) {
  9. resp, err := cli.get(ctx, "/version", nil, nil)
  10. if err != nil {
  11. return types.Version{}, err
  12. }
  13. var server types.Version
  14. err = json.NewDecoder(resp.body).Decode(&server)
  15. ensureReaderClosed(resp)
  16. return server, err
  17. }