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

..03-May-2022-

internal/H02-Oct-2018-1,254834

testing/H02-Oct-2018-6,7306,304

travis-scripts/H02-Oct-2018-3518

.gitignoreH A D02-Oct-201872 54

.travis.ymlH A D02-Oct-2018707 3130

AUTHORSH A D02-Oct-20182.8 KiB200198

DOCKER-LICENSEH A D02-Oct-2018276 75

Gopkg.tomlH A D02-Oct-2018631 2922

LICENSEH A D02-Oct-20181.3 KiB2419

MakefileH A D02-Oct-2018636 3525

README.markdownH A D02-Oct-20183.8 KiB13499

appveyor.ymlH A D02-Oct-2018652 2221

auth.goH A D02-Oct-20186.7 KiB237170

auth_test.goH A D02-Oct-20188.6 KiB236216

build_test.goH A D02-Oct-20184 KiB167145

change.goH A D02-Oct-2018944 4424

change_test.goH A D02-Oct-2018697 2619

client.goH A D02-Oct-201829.6 KiB1,094910

client_stress_test.goH A D02-Oct-20183.6 KiB136127

client_test.goH A D02-Oct-201828.1 KiB846792

client_unix.goH A D02-Oct-2018810 3320

client_unix_test.goH A D02-Oct-20181.6 KiB7060

client_windows.goH A D02-Oct-20181.1 KiB4632

client_windows_test.goH A D02-Oct-20181.1 KiB4530

container.goH A D02-Oct-201874.3 KiB1,6251,142

container_test.goH A D02-Oct-201890.4 KiB2,8082,657

container_unix_test.goH A D02-Oct-20182.8 KiB109100

distribution.goH A D02-Oct-2018792 2718

distribution_test.goH A D02-Oct-20181.2 KiB5549

env.goH A D02-Oct-20184.5 KiB173115

env_test.goH A D02-Oct-20189.1 KiB372345

event.goH A D02-Oct-201810.7 KiB411330

event_test.goH A D02-Oct-20188 KiB304257

example_test.goH A D02-Oct-20182.7 KiB139117

exec.goH A D02-Oct-20188.3 KiB218147

exec_test.goH A D02-Oct-20189.2 KiB309294

go.modH A D02-Oct-20182 KiB4341

go.sumH A D02-Oct-20187.1 KiB7978

image.goH A D02-Oct-201823.3 KiB714511

image_test.goH A D02-Oct-201833.8 KiB1,1751,112

integration_test.goH A D02-Oct-20182.2 KiB9582

misc.goH A D02-Oct-20185.1 KiB189132

misc_test.goH A D02-Oct-20185.1 KiB209196

network.goH A D02-Oct-201810.3 KiB325220

network_test.goH A D02-Oct-20188.4 KiB279259

plugin.goH A D02-Oct-201813.5 KiB419277

plugins_test.goH A D02-Oct-20188 KiB319295

registry_auth.goH A D02-Oct-2018253 115

signal.goH A D02-Oct-20181.3 KiB5039

swarm.goH A D02-Oct-20184.5 KiB157117

swarm_configs.goH A D02-Oct-20184.4 KiB172123

swarm_configs_test.goH A D02-Oct-20187.9 KiB252232

swarm_node.goH A D02-Oct-20183.2 KiB13193

swarm_node_test.goH A D02-Oct-20186.8 KiB262245

swarm_secrets.goH A D02-Oct-20184.4 KiB172123

swarm_secrets_test.goH A D02-Oct-20188.6 KiB286266

swarm_service.goH A D02-Oct-20185.8 KiB214153

swarm_service_test.goH A D02-Oct-201817.4 KiB616582

swarm_task.goH A D02-Oct-20181.7 KiB7149

swarm_task_test.goH A D02-Oct-20188.8 KiB377364

swarm_test.goH A D02-Oct-20187 KiB211194

system.goH A D02-Oct-20182.1 KiB7343

system_test.goH A D02-Oct-20182.8 KiB109101

tar.goH A D02-Oct-20183.4 KiB12389

tls.goH A D02-Oct-20183 KiB11984

volume.goH A D02-Oct-20185.3 KiB193133

volume_test.goH A D02-Oct-20185.8 KiB208192

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