Skip to content

Commit fd5ae34

Browse files
committed
Update docs
1 parent 6b5cea8 commit fd5ae34

File tree

4 files changed

+70
-13
lines changed

4 files changed

+70
-13
lines changed

docs/user_manual.md

+60-13
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ final ContainerInfo info = docker.inspectContainer("containerID");
138138

139139
### List processes running inside a container
140140

141-
Not implemented. PRs welcome.
141+
```java
142+
final TopResults topResults = docker.topContainer("containerID", "ps_args");
143+
```
142144

143145
### Get container logs
144146

@@ -151,7 +153,9 @@ try (LogStream stream = client.logs("containerID", LogsParam.stdout(), LogsParam
151153

152154
### Inspect changes on a container's filesystem
153155

154-
Not implemented. PRs welcome.
156+
```java
157+
final List<ContainerChange> changes = docker.inspectContainerChanges("containerId");
158+
```
155159

156160
### Export a container
157161

@@ -173,7 +177,11 @@ final ContainerStats stats = docker.stats("containerID");
173177

174178
### Resize a container TTY
175179

176-
Not implemented. PRs welcome.
180+
```java
181+
final int height = 10;
182+
final int width = 10;
183+
docker.resizeTty("containerID", height, width);
184+
```
177185

178186
### Start a container
179187

@@ -242,6 +250,8 @@ docker.removeContainer("containerID");
242250

243251
### Copy files or folders from a container
244252

253+
_NOTE: deprecated in favor of [archive](#get-an-archive-of-a-filesystem-resource-in-a-container)_
254+
245255
```java
246256
ImmutableSet.Builder<String> files = ImmutableSet.builder();
247257
try (TarArchiveInputStream tarStream =
@@ -253,6 +263,26 @@ try (TarArchiveInputStream tarStream =
253263
}
254264
```
255265

266+
### Retrieving information about files and folders in a container
267+
268+
Not implemented. PRs welcome.
269+
270+
### Get an archive of a filesystem resource in a container
271+
272+
```java
273+
try (final TarArchiveInputStream tarStream = new TarArchiveInputStream(docker.archiveContainer("containerID", "/file/path"))) {
274+
TarArchiveEntry entry;
275+
while ((entry = tarStream.getNextTarEntry()) != null) {
276+
// Do stuff with the files in the stream
277+
}
278+
}
279+
```
280+
281+
### Extract an archive of files or folders to a directory in a container
282+
283+
```java
284+
docker.copyToContainer("/local/path", "containerID", "/path/in/container");
285+
```
256286

257287
## Images
258288

@@ -292,7 +322,7 @@ docker.pull("dxia2/scratch-private:latest", authConfig);
292322
final File imageFile = new File("/path/to/image/file");
293323
final String image = "busybox-test" + System.nanoTime();
294324
try (InputStream imagePayload = new BufferedInputStream(new FileInputStream(imageFile))) {
295-
docker.load(image, imagePayload);
325+
docker.create(image, imagePayload);
296326
}
297327
```
298328

@@ -304,7 +334,9 @@ final ImageInfo info = docker.inspectImage("imageID")
304334

305335
### Get the history of an image
306336

307-
Not implemented yet. PRs welcome.
337+
```java
338+
final List<ImageHistory> imageHistoryList = docker.history("imageID");
339+
```
308340

309341
### Push an image on the registry
310342

@@ -432,7 +464,7 @@ final byte[] buffer = new byte[2048];
432464
int read;
433465

434466
try (OutputStream imageOutput = new BufferedOutputStream(new FileOutputStream(imageFile))) {
435-
try (InputStream imageInput = docker.save("busybox", authConfig)) {
467+
try (InputStream imageInput = docker.save("busybox")) {
436468
while ((read = imageInput.read(buffer)) > -1) {
437469
imageOutput.write(buffer, 0, read);
438470
}
@@ -443,11 +475,22 @@ try (OutputStream imageOutput = new BufferedOutputStream(new FileOutputStream(im
443475

444476
### Get a tarball containing all images.
445477

446-
Not implemented yet. PRs welcome.
478+
```java
479+
try (InputStream imageInput = docker.saveMultiple("image0", "image1")) {
480+
while ((read = imageInput.read(buffer)) > -1) {
481+
// Do stuff with the tar stream of images
482+
}
483+
}
484+
```
447485

448486
### Load a tarball with a set of images and tags into docker
449487

450-
Not implemented yet. PRs welcome.
488+
```
489+
final File tarFileWithMultipleImages = new File("/path/to/tarball");
490+
try (InputStream imagePayload = new BufferedInputStream(new FileInputStream(tarFileWithMultipleImages))) {
491+
docker.load(InputStream imagePayload);
492+
}
493+
```
451494

452495
### Exec Create
453496

@@ -474,20 +517,24 @@ See [example above](#exec-create).
474517

475518
### Exec Resize
476519

477-
Not implemented yet. PRs welcome.
520+
```java
521+
final int height = 10;
522+
final int width = 10;
523+
docker.execResizeTty("execID", height, width);
524+
```
478525

479526
### Exec Inspect
480527

481528
See [example above](#exec-create).
482529

483-
### Mounting volumes in a container
530+
### Mounting directories in a container
484531
To mount a host directory into a container, create the container with a `HostConfig`.
485532
You can set the local path and remote path in the `binds()` method on the `HostConfig.Builder`.
486533
There are two ways to make a bind:
487-
1. Pass `binds()` a set of strings of the form `"local_path:container_path"`.
488-
2. Create a `Bind` object and pass it to `binds()`.
534+
1. Pass `binds()` a set of strings of the form `"local_path:container_path"` for read/write or `"local_path:container_path:ro"` for read only.
535+
2. Create a `Bind` object and pass it to `binds()` (or `appendBinds()` if you want to incrementally add multiple `Bind`s).
489536

490-
If you only need to create a volume in a container, and you don't need it to mount any
537+
If you only need to create a volume to be mounted in a container, but you don't need it to be bound to any
491538
particular directory on the host, you can use the `volumes()` method on the
492539
`ContainerConfig.Builder`.
493540

src/main/java/com/spotify/docker/client/DefaultDockerClient.java

+2
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ public InputStream exportContainer(String containerId)
740740

741741

742742
@Override
743+
@Deprecated
743744
public InputStream copyContainer(String containerId, String path)
744745
throws DockerException, InterruptedException {
745746
final String apiVersion = version().apiVersion();
@@ -1074,6 +1075,7 @@ public InputStream save(final String... images)
10741075
}
10751076

10761077
@Override
1078+
@Deprecated
10771079
public InputStream save(final String image, final AuthConfig authConfig)
10781080
throws DockerException, IOException, InterruptedException {
10791081
return save(image);

src/main/java/com/spotify/docker/client/DockerClient.java

+4
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,9 @@ public static RemoveContainerParam forceKill(final boolean force) {
10801080
* if container is not found (404)
10811081
* @throws DockerException if a server error occurred (500)
10821082
* @throws InterruptedException If the thread is interrupted
1083+
* @deprecated Replaced by {@link #archiveContainer(String, String)}
10831084
*/
1085+
@Deprecated
10841086
InputStream copyContainer(String containerId, String path)
10851087
throws DockerException, InterruptedException;
10861088

@@ -1102,6 +1104,7 @@ InputStream copyContainer(String containerId, String path)
11021104
* if container is not found (404)
11031105
* @throws DockerException if a server error occurred (500)
11041106
* @throws InterruptedException If the thread is interrupted
1107+
* @since 1.20
11051108
*/
11061109
InputStream archiveContainer(String containerId, String path)
11071110
throws DockerException, InterruptedException;
@@ -1121,6 +1124,7 @@ InputStream archiveContainer(String containerId, String path)
11211124
* @throws DockerException If a server error occurred (500)
11221125
* @throws InterruptedException If the thread is interrupted
11231126
* @throws IOException If IOException
1127+
* @since 1.20
11241128
*/
11251129
void copyToContainer(final Path directory, String containerId, String path)
11261130
throws DockerException, InterruptedException, IOException;

src/test/java/com/spotify/docker/client/DefaultDockerClientTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ public void testExportContainer() throws Exception {
904904
}
905905

906906
@Test
907+
@SuppressWarnings("deprecation")
907908
public void testCopyContainer() throws Exception {
908909
requireDockerApiVersionLessThan("1.24", "failCopyToContainer");
909910

@@ -932,6 +933,7 @@ public void testCopyContainer() throws Exception {
932933
}
933934

934935
@Test
936+
@SuppressWarnings("deprecation")
935937
public void testFailCopyContainer() throws Exception {
936938
requireDockerApiVersionAtLeast("1.24", "failCopyToContainer");
937939

@@ -1143,6 +1145,7 @@ public void testRestartContainer() throws Exception {
11431145
}
11441146

11451147
@Test
1148+
@SuppressWarnings("deprecation")
11461149
public void integrationTest() throws Exception {
11471150
// Pull image
11481151
sut.pull(BUSYBOX_LATEST);
@@ -1929,6 +1932,7 @@ public void testLogDriver() throws Exception {
19291932
}
19301933

19311934
@Test
1935+
@SuppressWarnings("deprecation")
19321936
public void testContainerVolumesOldStyle() throws Exception {
19331937
requireDockerApiVersionLessThan("1.20",
19341938
"Creating a container with volumes and inspecting volumes in old style");

0 commit comments

Comments
 (0)