]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/fsouza/go-dockerclient/README.markdown
provider: Ensured Go 1.11 in TravisCI and README
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / fsouza / go-dockerclient / README.markdown
CommitLineData
9b12e4fe
JC
1# go-dockerclient
2
3[![Travis](https://img.shields.io/travis/fsouza/go-dockerclient/master.svg?style=flat-square)](https://travis-ci.org/fsouza/go-dockerclient)
4[![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/fsouza/go-dockerclient)
5
6This package presents a client for the Docker remote API. It also provides
7support for the extensions in the [Swarm API](https://docs.docker.com/swarm/swarm-api/).
8It currently supports the Docker API up to version 1.23.
9
10This package also provides support for docker's network API, which is a simple
11passthrough to the libnetwork remote API. Note that docker's network API is
12only available in docker 1.8 and above, and only enabled in docker if
13DOCKER_EXPERIMENTAL is defined during the docker build process.
14
15For more details, check the [remote API documentation](http://docs.docker.com/engine/reference/api/docker_remote_api/).
16
17## Vendoring
18
19If you are having issues with Go 1.5 and have `GO15VENDOREXPERIMENT` set with an application that has go-dockerclient vendored,
20please update your vendoring of go-dockerclient :) We recently moved the `vendor` directory to `external` so that go-dockerclient
21is compatible with this configuration. See [338](https://github.com/fsouza/go-dockerclient/issues/338) and [339](https://github.com/fsouza/go-dockerclient/pull/339)
22for details.
23
24## Example
25
26```go
27package main
28
29import (
30 "fmt"
31
32 "github.com/fsouza/go-dockerclient"
33)
34
35func main() {
36 endpoint := "unix:///var/run/docker.sock"
37 client, _ := docker.NewClient(endpoint)
38 imgs, _ := client.ListImages(docker.ListImagesOptions{All: false})
39 for _, img := range imgs {
40 fmt.Println("ID: ", img.ID)
41 fmt.Println("RepoTags: ", img.RepoTags)
42 fmt.Println("Created: ", img.Created)
43 fmt.Println("Size: ", img.Size)
44 fmt.Println("VirtualSize: ", img.VirtualSize)
45 fmt.Println("ParentId: ", img.ParentID)
46 }
47}
48```
49
50## Using with TLS
51
52In order to instantiate the client for a TLS-enabled daemon, you should use NewTLSClient, passing the endpoint and path for key and certificates as parameters.
53
54```go
55package main
56
57import (
58 "fmt"
59
60 "github.com/fsouza/go-dockerclient"
61)
62
63func main() {
64 endpoint := "tcp://[ip]:[port]"
65 path := os.Getenv("DOCKER_CERT_PATH")
66 ca := fmt.Sprintf("%s/ca.pem", path)
67 cert := fmt.Sprintf("%s/cert.pem", path)
68 key := fmt.Sprintf("%s/key.pem", path)
69 client, _ := docker.NewTLSClient(endpoint, cert, key, ca)
70 // use client
71}
72```
73
74If using [docker-machine](https://docs.docker.com/machine/), or another application that exports environment variables
75`DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH`, you can use NewClientFromEnv.
76
77
78```go
79package main
80
81import (
82 "fmt"
83
84 "github.com/fsouza/go-dockerclient"
85)
86
87func main() {
88 client, _ := docker.NewClientFromEnv()
89 // use client
90}
91```
92
93See the documentation for more details.
94
95## Developing
96
97All development commands can be seen in the [Makefile](Makefile).
98
99Commited code must pass:
100
101* [golint](https://github.com/golang/lint)
102* [go vet](https://godoc.org/golang.org/x/tools/cmd/vet)
103* [gofmt](https://golang.org/cmd/gofmt)
104* [go test](https://golang.org/cmd/go/#hdr-Test_packages)
105
106Running `make test` will check all of these. If your editor does not automatically call gofmt, `make fmt` will format all go files in this repository.