forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerClient.java
More file actions
442 lines (358 loc) · 14.3 KB
/
Copy pathDockerClient.java
File metadata and controls
442 lines (358 loc) · 14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
package com.github.dockerjava.api;
import com.github.dockerjava.api.command.AttachContainerCmd;
import com.github.dockerjava.api.command.AuthCmd;
import com.github.dockerjava.api.command.BuildImageCmd;
import com.github.dockerjava.api.command.CommitCmd;
import com.github.dockerjava.api.command.ConnectToNetworkCmd;
import com.github.dockerjava.api.command.ContainerDiffCmd;
import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd;
import com.github.dockerjava.api.command.CopyArchiveToContainerCmd;
import com.github.dockerjava.api.command.CopyFileFromContainerCmd;
import com.github.dockerjava.api.command.CreateContainerCmd;
import com.github.dockerjava.api.command.CreateImageCmd;
import com.github.dockerjava.api.command.CreateNetworkCmd;
import com.github.dockerjava.api.command.CreateSecretCmd;
import com.github.dockerjava.api.command.CreateServiceCmd;
import com.github.dockerjava.api.command.CreateVolumeCmd;
import com.github.dockerjava.api.command.DisconnectFromNetworkCmd;
import com.github.dockerjava.api.command.EventsCmd;
import com.github.dockerjava.api.command.ExecCreateCmd;
import com.github.dockerjava.api.command.ExecStartCmd;
import com.github.dockerjava.api.command.InfoCmd;
import com.github.dockerjava.api.command.InitializeSwarmCmd;
import com.github.dockerjava.api.command.InspectContainerCmd;
import com.github.dockerjava.api.command.InspectExecCmd;
import com.github.dockerjava.api.command.InspectImageCmd;
import com.github.dockerjava.api.command.InspectNetworkCmd;
import com.github.dockerjava.api.command.InspectServiceCmd;
import com.github.dockerjava.api.command.InspectSwarmCmd;
import com.github.dockerjava.api.command.InspectVolumeCmd;
import com.github.dockerjava.api.command.JoinSwarmCmd;
import com.github.dockerjava.api.command.KillContainerCmd;
import com.github.dockerjava.api.command.LeaveSwarmCmd;
import com.github.dockerjava.api.command.ListContainersCmd;
import com.github.dockerjava.api.command.ListImagesCmd;
import com.github.dockerjava.api.command.ListNetworksCmd;
import com.github.dockerjava.api.command.ListSecretsCmd;
import com.github.dockerjava.api.command.ListServicesCmd;
import com.github.dockerjava.api.command.ListSwarmNodesCmd;
import com.github.dockerjava.api.command.ListTasksCmd;
import com.github.dockerjava.api.command.ListVolumesCmd;
import com.github.dockerjava.api.command.LoadImageCmd;
import com.github.dockerjava.api.command.LogContainerCmd;
import com.github.dockerjava.api.command.LogSwarmObjectCmd;
import com.github.dockerjava.api.command.PauseContainerCmd;
import com.github.dockerjava.api.command.PingCmd;
import com.github.dockerjava.api.command.PruneCmd;
import com.github.dockerjava.api.command.PullImageCmd;
import com.github.dockerjava.api.command.PushImageCmd;
import com.github.dockerjava.api.command.RemoveContainerCmd;
import com.github.dockerjava.api.command.RemoveImageCmd;
import com.github.dockerjava.api.command.RemoveNetworkCmd;
import com.github.dockerjava.api.command.RemoveSecretCmd;
import com.github.dockerjava.api.command.RemoveServiceCmd;
import com.github.dockerjava.api.command.RemoveVolumeCmd;
import com.github.dockerjava.api.command.RenameContainerCmd;
import com.github.dockerjava.api.command.RestartContainerCmd;
import com.github.dockerjava.api.command.SaveImageCmd;
import com.github.dockerjava.api.command.SaveImagesCmd;
import com.github.dockerjava.api.command.SearchImagesCmd;
import com.github.dockerjava.api.command.StartContainerCmd;
import com.github.dockerjava.api.command.StatsCmd;
import com.github.dockerjava.api.command.StopContainerCmd;
import com.github.dockerjava.api.command.TagImageCmd;
import com.github.dockerjava.api.command.TopContainerCmd;
import com.github.dockerjava.api.command.UnpauseContainerCmd;
import com.github.dockerjava.api.command.UpdateContainerCmd;
import com.github.dockerjava.api.command.UpdateServiceCmd;
import com.github.dockerjava.api.command.UpdateSwarmCmd;
import com.github.dockerjava.api.command.UpdateSwarmNodeCmd;
import com.github.dockerjava.api.command.VersionCmd;
import com.github.dockerjava.api.command.WaitContainerCmd;
import com.github.dockerjava.api.exception.DockerException;
import com.github.dockerjava.api.model.AuthConfig;
import com.github.dockerjava.api.model.Identifier;
import com.github.dockerjava.api.model.PruneType;
import com.github.dockerjava.api.model.SecretSpec;
import com.github.dockerjava.api.model.ServiceSpec;
import com.github.dockerjava.api.model.SwarmSpec;
import javax.annotation.Nonnull;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
// https://godoc.org/github.com/fsouza/go-dockerclient
public interface DockerClient extends Closeable {
AuthConfig authConfig() throws DockerException;
/**
* Authenticate with the server, useful for checking authentication.
*/
AuthCmd authCmd();
InfoCmd infoCmd();
PingCmd pingCmd();
VersionCmd versionCmd();
/**
* * IMAGE API *
*/
PullImageCmd pullImageCmd(@Nonnull String repository);
PushImageCmd pushImageCmd(@Nonnull String name);
PushImageCmd pushImageCmd(@Nonnull Identifier identifier);
CreateImageCmd createImageCmd(@Nonnull String repository, @Nonnull InputStream imageStream);
/**
* Loads a tarball with a set of images and tags into a Docker repository.
*
* Corresponds to POST /images/load API endpoint.
*
* @param imageStream
* stream of the tarball file
* @return created command
* @since {@link RemoteApiVersion#VERSION_1_7}
*/
LoadImageCmd loadImageCmd(@Nonnull InputStream imageStream);
SearchImagesCmd searchImagesCmd(@Nonnull String term);
RemoveImageCmd removeImageCmd(@Nonnull String imageId);
ListImagesCmd listImagesCmd();
InspectImageCmd inspectImageCmd(@Nonnull String imageId);
/**
* @param name
* The name, e.g. "alexec/busybox" or just "busybox" if you want to default. Not null.
*/
SaveImageCmd saveImageCmd(@Nonnull String name);
/**
* Command to download multiple images at once.
* @return command (builder)
*/
SaveImagesCmd saveImagesCmd();
/**
* * CONTAINER API *
*/
ListContainersCmd listContainersCmd();
CreateContainerCmd createContainerCmd(@Nonnull String image);
/**
* Creates a new {@link StartContainerCmd} for the container with the given ID. The command can then be further customized by using
* builder methods on it like {@link StartContainerCmd#withDns(String...)}.
* <p>
* <b>If you customize the command, any existing configuration of the target container will get reset to its default before applying the
* new configuration. To preserve the existing configuration, use an unconfigured {@link StartContainerCmd}.</b>
* <p>
* This command corresponds to the <code>/containers/{id}/start</code> endpoint of the Docker Remote API.
*/
StartContainerCmd startContainerCmd(@Nonnull String containerId);
ExecCreateCmd execCreateCmd(@Nonnull String containerId);
InspectContainerCmd inspectContainerCmd(@Nonnull String containerId);
RemoveContainerCmd removeContainerCmd(@Nonnull String containerId);
WaitContainerCmd waitContainerCmd(@Nonnull String containerId);
AttachContainerCmd attachContainerCmd(@Nonnull String containerId);
ExecStartCmd execStartCmd(@Nonnull String execId);
InspectExecCmd inspectExecCmd(@Nonnull String execId);
LogContainerCmd logContainerCmd(@Nonnull String containerId);
/**
* Copy resource from container to local machine.
*
* @param containerId
* id of the container
* @param resource
* path to container's resource
* @return created command
* @since {@link RemoteApiVersion#VERSION_1_20}
*/
CopyArchiveFromContainerCmd copyArchiveFromContainerCmd(@Nonnull String containerId, @Nonnull String resource);
/**
* Copy resource from container to local machine.
*
* @param containerId
* id of the container
* @param resource
* path to container's resource
* @return created command
* @see #copyArchiveFromContainerCmd(String, String)
* @deprecated since docker API version 1.20, replaced by {@link #copyArchiveFromContainerCmd(String, String)}
* since 1.24 fails.
*/
@Deprecated
CopyFileFromContainerCmd copyFileFromContainerCmd(@Nonnull String containerId, @Nonnull String resource);
/**
* Copy archive from local machine to remote container
*
* @param containerId
* id of the container
* @return created command
* @since {@link RemoteApiVersion#VERSION_1_20}
*/
CopyArchiveToContainerCmd copyArchiveToContainerCmd(@Nonnull String containerId);
ContainerDiffCmd containerDiffCmd(@Nonnull String containerId);
StopContainerCmd stopContainerCmd(@Nonnull String containerId);
KillContainerCmd killContainerCmd(@Nonnull String containerId);
/**
* Update container settings
*
* @param containerId id of the container
* @return command
* @since {@link RemoteApiVersion#VERSION_1_22}
*/
UpdateContainerCmd updateContainerCmd(@Nonnull String containerId);
/**
* Rename container.
*
* @param containerId id of the container
* @return command
* @since {@link RemoteApiVersion#VERSION_1_17}
*/
RenameContainerCmd renameContainerCmd(@Nonnull String containerId);
RestartContainerCmd restartContainerCmd(@Nonnull String containerId);
CommitCmd commitCmd(@Nonnull String containerId);
BuildImageCmd buildImageCmd();
BuildImageCmd buildImageCmd(File dockerFileOrFolder);
BuildImageCmd buildImageCmd(InputStream tarInputStream);
TopContainerCmd topContainerCmd(String containerId);
TagImageCmd tagImageCmd(String imageId, String imageNameWithRepository, String tag);
PauseContainerCmd pauseContainerCmd(String containerId);
UnpauseContainerCmd unpauseContainerCmd(String containerId);
EventsCmd eventsCmd();
StatsCmd statsCmd(String containerId);
CreateVolumeCmd createVolumeCmd();
InspectVolumeCmd inspectVolumeCmd(String name);
RemoveVolumeCmd removeVolumeCmd(String name);
ListVolumesCmd listVolumesCmd();
ListNetworksCmd listNetworksCmd();
InspectNetworkCmd inspectNetworkCmd();
CreateNetworkCmd createNetworkCmd();
RemoveNetworkCmd removeNetworkCmd(@Nonnull String networkId);
ConnectToNetworkCmd connectToNetworkCmd();
DisconnectFromNetworkCmd disconnectFromNetworkCmd();
/**
* Enables swarm mode for the docker engine and creates a new swarm cluster
*
* @since 1.24
* @param swarmSpec the specification for the swarm
* @return the command
*/
InitializeSwarmCmd initializeSwarmCmd(SwarmSpec swarmSpec);
/**
* Gets information about the swarm the docker engine is currently in
*
* @since 1.24
* @return the command
*/
InspectSwarmCmd inspectSwarmCmd();
/**
* Enables swarm mode for the docker engine and joins an existing swarm cluster
*
* @since 1.24
* @return the command
*/
JoinSwarmCmd joinSwarmCmd();
/**
* Disables swarm node for the docker engine and leaves the swarm cluster
*
* @since 1.24
* @return the command
*/
LeaveSwarmCmd leaveSwarmCmd();
/**
* Updates the swarm specification
*
* @since 1.24
* @param swarmSpec the specification for the swarm
* @return the command
*/
UpdateSwarmCmd updateSwarmCmd(SwarmSpec swarmSpec);
/**
* Updates the swarm node
*
* @return the command
* @since 1.24
*/
UpdateSwarmNodeCmd updateSwarmNodeCmd();
/**
* List nodes in swarm
*
* @return the command
* @since 1.24
*/
ListSwarmNodesCmd listSwarmNodesCmd();
/**
* Command to list all services in a docker swarm. Only applicable if docker runs in swarm mode.
*
* @since {@link RemoteApiVersion#VERSION_1_24}
* @return command
*/
ListServicesCmd listServicesCmd();
/**
* Command to create a service in a docker swarm. Only applicable if docker runs in swarm mode.
*
* @since {@link RemoteApiVersion#VERSION_1_24}
* @param serviceSpec the service specification
* @return command
*/
CreateServiceCmd createServiceCmd(ServiceSpec serviceSpec);
/**
* Command to inspect a service
* @param serviceId service id or service name
* @return command
*/
InspectServiceCmd inspectServiceCmd(String serviceId);
/**
* Command to update a service specification
* @param serviceId service id
* @param serviceSpec the new service specification
* @return command
*/
UpdateServiceCmd updateServiceCmd(String serviceId, ServiceSpec serviceSpec);
/**
* Command to remove a service
* @param serviceId service id or service name
* @return command
*/
RemoveServiceCmd removeServiceCmd(String serviceId);
/**
* List tasks in the swarm cluster
*
* @return the command
* @since 1.24
*/
ListTasksCmd listTasksCmd();
/**
* Command to get service log
*
* @return the command
* @since 1.29
*/
LogSwarmObjectCmd logServiceCmd(String serviceId);
/**
* Command to get task log
*
* @return the command
* @since 1.29
*/
LogSwarmObjectCmd logTaskCmd(String taskId);
/**
* Command to delete unused containers/images/networks/volumes
*
* @since {@link RemoteApiVersion#VERSION_1_25}
*/
PruneCmd pruneCmd(PruneType pruneType);
/**
* Command to list all secrets. Only applicable if docker runs in swarm mode.
*
* @since {@link RemoteApiVersion#VERSION_1_25}
* @return command
*/
ListSecretsCmd listSecretsCmd();
/**
* Command to create a secret in a docker swarm. Only applicable if docker runs in swarm mode.
*
* @since {@link RemoteApiVersion#VERSION_1_25}
* @param secretSpec the secret specification
* @return command
*/
CreateSecretCmd createSecretCmd(SecretSpec secretSpec);
/**
* Command to remove a secret
* @param secretId secret id or secret name
* @return command
*/
RemoveSecretCmd removeSecretCmd(String secretId);
@Override
void close() throws IOException;
}