Skip to content

Commit a00106f

Browse files
committed
Add a README to the client's package…
… taken from the old engine-api project. Signed-off-by: Vincent Demeester <[email protected]>
1 parent 2cce7bf commit a00106f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

client/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Client
2+
3+
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.
4+
5+
### Usage
6+
7+
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:
8+
9+
```go
10+
package main
11+
12+
import (
13+
"fmt"
14+
15+
"github.com/docker/docker/client"
16+
"github.com/docker/docker/api/types"
17+
"golang.org/x/net/context"
18+
)
19+
20+
func main() {
21+
defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"}
22+
cli, err := client.NewClient("unix:///var/run/docker.sock", "v1.22", nil, defaultHeaders)
23+
if err != nil {
24+
panic(err)
25+
}
26+
27+
options := types.ContainerListOptions{All: true}
28+
containers, err := cli.ContainerList(context.Background(), options)
29+
if err != nil {
30+
panic(err)
31+
}
32+
33+
for _, c := range containers {
34+
fmt.Println(c.ID)
35+
}
36+
}
37+
```

0 commit comments

Comments
 (0)