|
1 | 1 | [](https://gitter.im/docker-java/docker-java?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
2 | 2 | [](https://mvnrepository.com/artifact/com.github.docker-java/docker-java) |
3 | | -[](https://bintray.com/kostyasha/maven/com.github.docker-java%3Adocker-java/_latestVersion) |
4 | | -[](https://travis-ci.org/docker-java/docker-java) |
5 | | -[](https://scan.coverity.com/projects/9177) |
6 | 3 | [](http://codecov.io/github/docker-java/docker-java?branch=master) |
7 | 4 | [](https://github.com/docker-java/docker-java/blob/master/LICENSE) |
8 | | - |
9 | | -<!--[](https://circleci.com/gh/docker-java/docker-java)--> |
10 | 5 | # docker-java |
11 | 6 |
|
12 | 7 | Java API client for [Docker](http://docs.docker.io/ "Docker") |
13 | 8 |
|
14 | | -[Changelog](https://github.com/docker-java/docker-java/blob/master/CHANGELOG.md)<br/> |
15 | | -[Wiki](https://github.com/docker-java/docker-java/wiki) |
16 | | - |
17 | | -## Build with Maven |
18 | | - |
19 | | -###### Prerequisites: |
20 | | - |
21 | | -* Java min 1.8 |
22 | | -* Maven 3 |
23 | | - |
24 | | -Build and run integration tests as follows: |
25 | | - |
26 | | - $ mvn clean install |
27 | | - |
28 | | -If you do not have access to a Docker server or just want to execute the build quickly, you can run the build without the integration tests: |
29 | | - |
30 | | - $ mvn clean install -DskipITs |
31 | | - |
32 | | -By default the docker engine is using local UNIX sockets for communication with the docker CLI so docker-java |
33 | | -client also uses UNIX domain sockets to connect to the docker daemon by default. To make the docker daemon listening on a TCP (http/https) port you have to configure it by setting the DOCKER_OPTS environment variable to something like the following: |
34 | | - |
35 | | - DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock" |
36 | | - |
37 | | -More details about setting up Docker Engine can be found in the official documentation: https://docs.docker.com/engine/admin/ |
38 | | - |
39 | | -To force docker-java to use TCP (http) configure the following (see [Configuration](https://github.com/docker-java/docker-java#configuration) for details): |
40 | | - |
41 | | - DOCKER_HOST=tcp://127.0.0.1:2375 |
42 | | - |
43 | | -For secure tls (https) communication: |
44 | | - |
45 | | - DOCKER_HOST=tcp://127.0.0.1:2376 |
46 | | - DOCKER_TLS_VERIFY=1 |
47 | | - DOCKER_CERT_PATH=/Users/marcus/.docker/machine/machines/docker-1.11.2 |
48 | | - |
49 | | -### Latest release version |
50 | | -[Maven repository modules](https://mvnrepository.com/artifact/com.github.docker-java) |
51 | | - |
52 | | -Since 3.2.0 project provides 3 transports: |
53 | | -- `docker-java-transport-jersey` (doesn't support streams) |
54 | | -- `docker-java-transport-netty` |
55 | | -- `docker-java-transport-okhttp` |
56 | | - |
57 | | -For backward compatibility `docker-java` module keeping dependency only on jersey and netty transports. |
58 | | - |
59 | | - <dependency> |
60 | | - <groupId>com.github.docker-java</groupId> |
61 | | - <artifactId>docker-java</artifactId> |
62 | | - <!-- use latest version https://github.com/docker-java/docker-java/releases --> |
63 | | - <version>3.X.Y</version> |
64 | | - </dependency> |
65 | | - |
66 | | -### Latest development version |
67 | | -May contain new features while they are not released. |
68 | | - |
69 | | -You can find the latest development version including javadoc and source files on [Sonatypes OSS repository](https://oss.sonatype.org/content/groups/public/com/github/docker-java/docker-java/). |
70 | | - |
71 | | - <dependency> |
72 | | - <groupId>com.github.docker-java</groupId> |
73 | | - <artifactId>docker-java</artifactId> |
74 | | - <version>3.X.Y-SNAPSHOT</version> |
75 | | - </dependency> |
76 | | - |
77 | | - |
78 | | -## Documentation |
79 | | - |
80 | | -For code examples, please look at the [Wiki](https://github.com/docker-java/docker-java/wiki) or [Test cases](https://github.com/docker-java/docker-java/tree/master/docker-java/src/test/java/com/github/dockerjava/core/command "Test cases") |
81 | | - |
82 | | -## Configuration |
83 | | - |
84 | | -There are a couple of configuration items, all of which have sensible defaults: |
85 | | - |
86 | | -* `DOCKER_HOST` The Docker Host URL, e.g. `tcp://localhost:2376` or `unix:///var/run/docker.sock` |
87 | | -* `DOCKER_TLS_VERIFY` enable/disable TLS verification (switch between `http` and `https` protocol) |
88 | | -* `DOCKER_CERT_PATH` Path to the certificates needed for TLS verification |
89 | | -* `DOCKER_CONFIG` Path for additional docker configuration files (like `.dockercfg`) |
90 | | -* `api.version` The API version, e.g. `1.23`. |
91 | | -* `registry.url` Your registry's address. |
92 | | -* `registry.username` Your registry username (required to push containers). |
93 | | -* `registry.password` Your registry password. |
94 | | -* `registry.email` Your registry email. |
95 | | - |
96 | | -There are three ways to configure, in descending order of precedence: |
97 | | - |
98 | | -#### Programmatic: |
99 | | -In your application, e.g. |
100 | | - |
101 | | - DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder() |
102 | | - .withDockerHost("tcp://my-docker-host.tld:2376") |
103 | | - .withDockerTlsVerify(true) |
104 | | - .withDockerCertPath("/home/user/.docker/certs") |
105 | | - .withDockerConfig("/home/user/.docker") |
106 | | - .withApiVersion("1.30") // optional |
107 | | - .withRegistryUrl("https://index.docker.io/v1/") |
108 | | - .withRegistryUsername("dockeruser") |
109 | | - .withRegistryPassword("ilovedocker") |
110 | | - .withRegistryEmail("dockeruser@github.com") |
111 | | - .build(); |
112 | | - DockerClient docker = DockerClientBuilder.getInstance(config).build(); |
113 | | - |
114 | | -#### Properties (docker-java.properties) |
115 | | - |
116 | | - DOCKER_HOST=tcp://localhost:2376 |
117 | | - DOCKER_TLS_VERIFY=1 |
118 | | - DOCKER_CERT_PATH=/home/user/.docker/certs |
119 | | - DOCKER_CONFIG=/home/user/.docker |
120 | | - api.version=1.23 |
121 | | - registry.url=https://index.docker.io/v1/ |
122 | | - registry.username=dockeruser |
123 | | - registry.password=ilovedocker |
124 | | - registry.email=dockeruser@github.com |
125 | | - |
126 | | -##### System Properties: |
127 | | - |
128 | | - java -DDOCKER_HOST=tcp://localhost:2375 -Dregistry.username=dockeruser pkg.Main |
129 | | - |
130 | | -##### System Environment |
131 | | - |
132 | | - export DOCKER_HOST=tcp://localhost:2376 |
133 | | - export DOCKER_TLS_VERIFY=1 |
134 | | - export DOCKER_CERT_PATH=/home/user/.docker/certs |
135 | | - export DOCKER_CONFIG=/home/user/.docker |
136 | | - |
137 | | -##### File System |
138 | | - |
139 | | -In `$HOME/.docker-java.properties` |
140 | | - |
141 | | -##### Class Path |
142 | | - |
143 | | -In the class path at `/docker-java.properties` |
| 9 | +# [Read the documentation here](docs/README.md) |
0 commit comments