@@ -138,7 +138,9 @@ final ContainerInfo info = docker.inspectContainer("containerID");
138
138
139
139
### List processes running inside a container
140
140
141
- Not implemented. PRs welcome.
141
+ ``` java
142
+ final TopResults topResults = docker. topContainer(" containerID" , " ps_args" );
143
+ ```
142
144
143
145
### Get container logs
144
146
@@ -151,7 +153,9 @@ try (LogStream stream = client.logs("containerID", LogsParam.stdout(), LogsParam
151
153
152
154
### Inspect changes on a container's filesystem
153
155
154
- Not implemented. PRs welcome.
156
+ ``` java
157
+ final List<ContainerChange > changes = docker. inspectContainerChanges(" containerId" );
158
+ ```
155
159
156
160
### Export a container
157
161
@@ -173,7 +177,11 @@ final ContainerStats stats = docker.stats("containerID");
173
177
174
178
### Resize a container TTY
175
179
176
- Not implemented. PRs welcome.
180
+ ``` java
181
+ final int height = 10 ;
182
+ final int width = 10 ;
183
+ docker. resizeTty(" containerID" , height, width);
184
+ ```
177
185
178
186
### Start a container
179
187
@@ -242,6 +250,8 @@ docker.removeContainer("containerID");
242
250
243
251
### Copy files or folders from a container
244
252
253
+ _ NOTE: deprecated in favor of [ archive] ( #get-an-archive-of-a-filesystem-resource-in-a-container ) _
254
+
245
255
``` java
246
256
ImmutableSet . Builder<String > files = ImmutableSet . builder();
247
257
try (TarArchiveInputStream tarStream =
@@ -253,6 +263,26 @@ try (TarArchiveInputStream tarStream =
253
263
}
254
264
```
255
265
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
+ ```
256
286
257
287
## Images
258
288
@@ -292,7 +322,7 @@ docker.pull("dxia2/scratch-private:latest", authConfig);
292
322
final File imageFile = new File (" /path/to/image/file" );
293
323
final String image = " busybox-test" + System . nanoTime();
294
324
try (InputStream imagePayload = new BufferedInputStream (new FileInputStream (imageFile))) {
295
- docker. load (image, imagePayload);
325
+ docker. create (image, imagePayload);
296
326
}
297
327
```
298
328
@@ -304,7 +334,9 @@ final ImageInfo info = docker.inspectImage("imageID")
304
334
305
335
### Get the history of an image
306
336
307
- Not implemented yet. PRs welcome.
337
+ ``` java
338
+ final List<ImageHistory > imageHistoryList = docker. history(" imageID" );
339
+ ```
308
340
309
341
### Push an image on the registry
310
342
@@ -432,7 +464,7 @@ final byte[] buffer = new byte[2048];
432
464
int read;
433
465
434
466
try (OutputStream imageOutput = new BufferedOutputStream (new FileOutputStream (imageFile))) {
435
- try (InputStream imageInput = docker. save(" busybox" , authConfig )) {
467
+ try (InputStream imageInput = docker. save(" busybox" )) {
436
468
while ((read = imageInput. read(buffer)) > - 1 ) {
437
469
imageOutput. write(buffer, 0 , read);
438
470
}
@@ -443,11 +475,22 @@ try (OutputStream imageOutput = new BufferedOutputStream(new FileOutputStream(im
443
475
444
476
### Get a tarball containing all images.
445
477
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
+ ```
447
485
448
486
### Load a tarball with a set of images and tags into docker
449
487
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
+ ```
451
494
452
495
### Exec Create
453
496
@@ -474,20 +517,24 @@ See [example above](#exec-create).
474
517
475
518
### Exec Resize
476
519
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
+ ```
478
525
479
526
### Exec Inspect
480
527
481
528
See [ example above] ( #exec-create ) .
482
529
483
- ### Mounting volumes in a container
530
+ ### Mounting directories in a container
484
531
To mount a host directory into a container, create the container with a ` HostConfig ` .
485
532
You can set the local path and remote path in the ` binds() ` method on the ` HostConfig.Builder ` .
486
533
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) .
489
536
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
491
538
particular directory on the host, you can use the ` volumes() ` method on the
492
539
` ContainerConfig.Builder ` .
493
540
0 commit comments