Skip to content

Commit 26b4069

Browse files
committed
Update README.md
1 parent 8f49622 commit 26b4069

File tree

1 file changed

+2
-144
lines changed

1 file changed

+2
-144
lines changed

README.md

Lines changed: 2 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,3 @@
1-
# docker-java
1+
This project has moved to https://github.com/docker-java/docker-java
2+
--------------------------------------------------------------------
23

3-
Java API client for [Docker](http://docs.docker.io/ "Docker")
4-
5-
Supports a subset of the Docker Client API v1.11, Docker Server version 0.11
6-
7-
Developer forum for [docker-java](https://groups.google.com/forum/?hl=de#!forum/docker-java-dev "docker-java")
8-
9-
## Build with Maven
10-
11-
###### Prerequisites:
12-
13-
* Java 1.6+
14-
* Maven 3.0.5
15-
* Docker daemon running
16-
17-
Maven may run tests during build process but tests are disabled by default. The tests are using a localhost instance of Docker, make sure that you have Docker running for tests to work. To run the tests you have to provide your https://www.docker.io/account/login/ information:
18-
19-
$ mvn clean install -DskipTests=false -Ddocker.io.username=... -Ddocker.io.password=... -Ddocker.io.email=...
20-
21-
By default Docker server is using UNIX sockets for communication with the Docker client, however docker-java
22-
client uses TCP/IP to connect to the Docker server, so you will need to make sure that your Docker server is
23-
listening on TCP port. To allow Docker server to use TCP add the following line to /etc/default/docker
24-
25-
DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"
26-
27-
More details setting up docket server can be found in official documentation: http://docs.docker.io/en/latest/use/basics/
28-
29-
Now make sure that docker is up:
30-
31-
$ docker -H tcp://127.0.0.1:4243 version
32-
33-
Client version: 0.8.1
34-
Go version (client): go1.2
35-
Git commit (client): a1598d1
36-
Server version: 0.8.1
37-
Git commit (server): a1598d1
38-
Go version (server): go1.2
39-
Last stable version: 0.8.1
40-
41-
Run build with tests:
42-
43-
$ mvn clean install
44-
45-
## Docker-Java maven dependency:
46-
47-
<dependency>
48-
<groupId>com.kpelykh</groupId>
49-
<artifactId>docker-java</artifactId>
50-
<version>0.8.1</version>
51-
</dependency>
52-
53-
54-
## Example code snippets:
55-
56-
DockerClient dockerClient = new DockerClient("http://localhost:4243");
57-
58-
###### Get Docker info:
59-
60-
Info info = dockerClient.info();
61-
System.out.print(info);
62-
63-
###### Search Docker repository:
64-
65-
List<SearchItem> dockerSearch = dockerClient.search("busybox");
66-
System.out.println("Search returned" + dockerSearch.toString());
67-
68-
###### Create new Docker container, wait for its start and stop it:
69-
70-
ContainerConfig containerConfig = new ContainerConfig();
71-
containerConfig.setImage("busybox");
72-
containerConfig.setCmd(new String[] {"touch", "/test"});
73-
ContainerCreateResponse container = dockerClient.createContainer(containerConfig);
74-
75-
dockerClient.startContainer(container.id);
76-
77-
dockerClient.waitContainer(container.id);
78-
79-
dockerClient.stopContainer(container.id);
80-
81-
82-
##### Support for UNIX sockets:
83-
84-
Support for UNIX socket should appear in docker-java pretty soon. I'm working on its integration.
85-
86-
##### Docker Builder:
87-
88-
To use Docker Builder, as described on page http://docs.docker.io/en/latest/use/builder/,
89-
user dockerClient.build(baseDir), where baseDir is a path to folder containing Dockerfile.
90-
91-
92-
File baseDir = new File("~/kpelykh/docker/netcat");
93-
94-
ClientResponse response = dockerClient.build(baseDir);
95-
96-
StringWriter logwriter = new StringWriter();
97-
98-
try {
99-
LineIterator itr = IOUtils.lineIterator(response.getEntityInputStream(), "UTF-8");
100-
while (itr.hasNext()) {
101-
String line = itr.next();
102-
logwriter.write(line);
103-
LOG.info(line);
104-
}
105-
} finally {
106-
IOUtils.closeQuietly(response.getEntityInputStream());
107-
}
108-
109-
110-
111-
For additional examples, please look at [DockerClientTest.java](https://github.com/kpelykh/docker-java/blob/master/src/test/java/com/kpelykh/docker/client/test/DockerClientTest.java "DockerClientTest.java")
112-
113-
## Configuration
114-
115-
There are a couple of configuration items, all of which have sensible defaults:
116-
117-
* `url` The Docker URL, e.g. `http://localhost:4243`.
118-
* `version` The API version, e.g. `1.11`.
119-
* `username` Your repository username (required to push containers).
120-
* `password` Your repository password.
121-
* `email` Your repository email.
122-
123-
There are three ways to configure, in descending order of precedence:
124-
125-
##### Programatic:
126-
In your application, e.g.
127-
128-
DockerClient docker = new DockerClient("http://localhost:4243");
129-
docker.setCredentials("dockeruser", "ilovedocker", "dockeruser@github.com");`
130-
131-
##### System Properties:
132-
E.g.
133-
134-
java -Ddocker.io.username=kpelykh pkg.Main
135-
136-
##### File System
137-
In `$HOME/.docker.io.properties`, e.g.:
138-
139-
docker.io.username=dockeruser
140-
141-
##### Class Path
142-
In the class path at `/docker.io.properties`, e.g.:
143-
144-
docker.io.url=http://localhost:4243
145-
docker.io.version=1.11

0 commit comments

Comments
 (0)