2018-02-05 21:05:59 +00:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2016-09-06 18:46:37 +00:00
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2016-09-06 18:46:37 +00:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"net/url"
|
|
|
|
|
2023-07-03 11:14:14 +00:00
|
|
|
"github.com/docker/docker/api/types/system"
|
2016-09-06 18:46:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Info returns information about the docker server.
|
2023-07-03 11:14:14 +00:00
|
|
|
func (cli *Client) Info(ctx context.Context) (system.Info, error) {
|
|
|
|
var info system.Info
|
2016-09-06 18:46:37 +00:00
|
|
|
serverResp, err := cli.get(ctx, "/info", url.Values{}, nil)
|
2019-02-11 12:26:12 +00:00
|
|
|
defer ensureReaderClosed(serverResp)
|
2016-09-06 18:46:37 +00:00
|
|
|
if err != nil {
|
|
|
|
return info, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := json.NewDecoder(serverResp.body).Decode(&info); err != nil {
|
|
|
|
return info, fmt.Errorf("Error reading remote info: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return info, nil
|
|
|
|
}
|