From 62e14c713b444f2566b1dffc79f68718608011ff Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Mon, 12 Sep 2016 11:41:11 +0200 Subject: [PATCH] =?UTF-8?q?Add=20a=20README=20to=20the=20client's=20packag?= =?UTF-8?q?e=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … taken from the old engine-api project. Signed-off-by: Vincent Demeester --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..7872d94a53 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +## Client + +The client package implements a fully featured http client to interact with the Docker engine. It's modeled after the requirements of the Docker engine CLI, but it can also serve other purposes. + +### Usage + +You can use this client package in your applications by creating a new client object. Then use that object to execute operations against the remote server. Follow the example below to see how to list all the containers running in a Docker engine host: + +```go +package main + +import ( + "fmt" + + "github.com/docker/docker/client" + "github.com/docker/docker/api/types" + "golang.org/x/net/context" +) + +func main() { + defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"} + cli, err := client.NewClient("unix:///var/run/docker.sock", "v1.22", nil, defaultHeaders) + if err != nil { + panic(err) + } + + options := types.ContainerListOptions{All: true} + containers, err := cli.ContainerList(context.Background(), options) + if err != nil { + panic(err) + } + + for _, c := range containers { + fmt.Println(c.ID) + } +} +```