• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

internal/H02-Oct-2018-

testing/H02-Oct-2018-

travis-scripts/H02-Oct-2018-

.gitignoreH A D02-Oct-201872

.travis.ymlH A D02-Oct-2018707

AUTHORSH A D02-Oct-20182.8 KiB

DOCKER-LICENSEH A D02-Oct-2018276

Gopkg.tomlH A D02-Oct-2018631

LICENSEH A D02-Oct-20181.3 KiB

MakefileH A D02-Oct-2018636

README.markdownH A D02-Oct-20183.8 KiB

appveyor.ymlH A D02-Oct-2018652

auth.goH A D02-Oct-20186.7 KiB

auth_test.goH A D02-Oct-20188.6 KiB

build_test.goH A D02-Oct-20184 KiB

change.goH A D02-Oct-2018944

change_test.goH A D02-Oct-2018697

client.goH A D02-Oct-201829.6 KiB

client_stress_test.goH A D02-Oct-20183.6 KiB

client_test.goH A D02-Oct-201828.1 KiB

client_unix.goH A D02-Oct-2018810

client_unix_test.goH A D02-Oct-20181.6 KiB

client_windows.goH A D02-Oct-20181.1 KiB

client_windows_test.goH A D02-Oct-20181.1 KiB

container.goH A D02-Oct-201874.3 KiB

container_test.goH A D02-Oct-201890.4 KiB

container_unix_test.goH A D02-Oct-20182.8 KiB

distribution.goH A D02-Oct-2018792

distribution_test.goH A D02-Oct-20181.2 KiB

env.goH A D02-Oct-20184.5 KiB

env_test.goH A D02-Oct-20189.1 KiB

event.goH A D02-Oct-201810.7 KiB

event_test.goH A D02-Oct-20188 KiB

example_test.goH A D02-Oct-20182.7 KiB

exec.goH A D02-Oct-20188.3 KiB

exec_test.goH A D02-Oct-20189.2 KiB

go.modH A D02-Oct-20182 KiB

go.sumH A D02-Oct-20187.1 KiB

image.goH A D02-Oct-201823.3 KiB

image_test.goH A D02-Oct-201833.8 KiB

integration_test.goH A D02-Oct-20182.2 KiB

misc.goH A D02-Oct-20185.1 KiB

misc_test.goH A D02-Oct-20185.1 KiB

network.goH A D02-Oct-201810.3 KiB

network_test.goH A D02-Oct-20188.4 KiB

plugin.goH A D02-Oct-201813.5 KiB

plugins_test.goH A D02-Oct-20188 KiB

registry_auth.goH A D02-Oct-2018253

signal.goH A D02-Oct-20181.3 KiB

swarm.goH A D02-Oct-20184.5 KiB

swarm_configs.goH A D02-Oct-20184.4 KiB

swarm_configs_test.goH A D02-Oct-20187.9 KiB

swarm_node.goH A D02-Oct-20183.2 KiB

swarm_node_test.goH A D02-Oct-20186.8 KiB

swarm_secrets.goH A D02-Oct-20184.4 KiB

swarm_secrets_test.goH A D02-Oct-20188.6 KiB

swarm_service.goH A D02-Oct-20185.8 KiB

swarm_service_test.goH A D02-Oct-201817.4 KiB

swarm_task.goH A D02-Oct-20181.7 KiB

swarm_task_test.goH A D02-Oct-20188.8 KiB

swarm_test.goH A D02-Oct-20187 KiB

system.goH A D02-Oct-20182.1 KiB

system_test.goH A D02-Oct-20182.8 KiB

tar.goH A D02-Oct-20183.4 KiB

tls.goH A D02-Oct-20183 KiB

volume.goH A D02-Oct-20185.3 KiB

volume_test.goH A D02-Oct-20185.8 KiB

README.markdown

1# go-dockerclient
2
3[![Travis Build Status](https://travis-ci.org/fsouza/go-dockerclient.svg?branch=master)](https://travis-ci.org/fsouza/go-dockerclient)
4[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/4m374pti06ubg2l7?svg=true)](https://ci.appveyor.com/project/fsouza/go-dockerclient)
5[![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/fsouza/go-dockerclient)
6
7This package presents a client for the Docker remote API. It also provides
8support for the extensions in the [Swarm API](https://docs.docker.com/swarm/swarm-api/).
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
16documentation](http://docs.docker.com/engine/reference/api/docker_remote_api/).
17
18## Example
19
20```go
21package main
22
23import (
24	"fmt"
25
26	"github.com/fsouza/go-dockerclient"
27)
28
29func main() {
30	endpoint := "unix:///var/run/docker.sock"
31	client, err := docker.NewClient(endpoint)
32	if err != nil {
33		panic(err)
34	}
35	imgs, err := client.ListImages(docker.ListImagesOptions{All: false})
36	if err != nil {
37		panic(err)
38	}
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
53NewTLSClient, passing the endpoint and path for key and certificates as
54parameters.
55
56```go
57package main
58
59import (
60	"fmt"
61
62	"github.com/fsouza/go-dockerclient"
63)
64
65func main() {
66	endpoint := "tcp://[ip]:[port]"
67	path := os.Getenv("DOCKER_CERT_PATH")
68	ca := fmt.Sprintf("%s/ca.pem", path)
69	cert := fmt.Sprintf("%s/cert.pem", path)
70	key := fmt.Sprintf("%s/key.pem", path)
71	client, _ := docker.NewTLSClient(endpoint, cert, key, ca)
72	// use client
73}
74```
75
76If using [docker-machine](https://docs.docker.com/machine/), or another
77application that exports environment variables `DOCKER_HOST`,
78`DOCKER_TLS_VERIFY`, `DOCKER_CERT_PATH`, you can use NewClientFromEnv.
79
80
81```go
82package main
83
84import (
85	"fmt"
86
87	"github.com/fsouza/go-dockerclient"
88)
89
90func main() {
91	client, _ := docker.NewClientFromEnv()
92	// use client
93}
94```
95
96See the documentation for more details.
97
98## Developing
99
100All development commands can be seen in the [Makefile](Makefile).
101
102Commited code must pass:
103
104* [golint](https://github.com/golang/lint) (with some exceptions, see the Makefile).
105* [go vet](https://golang.org/cmd/vet/)
106* [gofmt](https://golang.org/cmd/gofmt)
107* [go test](https://golang.org/cmd/go/#hdr-Test_packages)
108
109Running `make test` will check all of these. If your editor does not
110automatically call ``gofmt -s``, `make fmt` will format all go files in this
111repository.
112
113## Vendoring
114
115go-dockerclient uses [dep](https://github.com/golang/dep/) for vendoring. If
116you're using dep, you should be able to pick go-dockerclient releases and get
117the proper dependencies.
118
119With other vendoring tools, users might need to specify go-dockerclient's
120dependencies manually.
121
122## Using with Docker 1.9 and Go 1.4
123
124There's a tag for using go-dockerclient with Docker 1.9 (which requires
125compiling go-dockerclient with Go 1.4), the tag name is ``docker-1.9/go-1.4``.
126
127The instructions below can be used to get a version of go-dockerclient that compiles with Go 1.4:
128
129```
130% git clone -b docker-1.9/go-1.4 https://github.com/fsouza/go-dockerclient.git $GOPATH/src/github.com/fsouza/go-dockerclient
131% git clone -b v1.9.1 https://github.com/docker/docker.git $GOPATH/src/github.com/docker/docker
132% go get github.com/fsouza/go-dockerclient
133```
134