public class DefaultDockerClient extends Object implements DockerClient
| Modifier and Type | Class and Description |
|---|---|
static interface |
DefaultDockerClient.ExceptionPropagator |
DockerClient.ListContainersParam, DockerClient.LogsParameter| Modifier and Type | Field and Description |
|---|---|
private com.sun.jersey.api.client.Client |
client |
private static com.sun.jersey.api.client.config.DefaultClientConfig |
CLIENT_CONFIG |
private static long |
CONNECT_TIMEOUT_MILLIS |
private static com.sun.jersey.api.client.GenericType<List<Container>> |
CONTAINER_LIST |
private static Pattern |
CONTAINER_NAME_PATTERN |
private static org.slf4j.Logger |
log |
private static long |
READ_TIMEOUT_MILLIS |
private static com.sun.jersey.api.client.GenericType<List<RemovedImage>> |
REMOVED_IMAGE_LIST |
private URI |
uri |
private static String |
VERSION |
| Constructor and Description |
|---|
DefaultDockerClient(String uri) |
DefaultDockerClient(URI uri) |
| Modifier and Type | Method and Description |
|---|---|
ContainerCreation |
createContainer(ContainerConfig config)
Create a docker container.
|
ContainerCreation |
createContainer(ContainerConfig config,
String name)
Create a docker container.
|
ContainerInfo |
inspectContainer(String containerId)
Inspect a docker container.
|
ImageInfo |
inspectImage(String image)
Inspect a docker container image.
|
void |
killContainer(String containerId)
Kill a docker container.
|
List<Container> |
listContainers(DockerClient.ListContainersParam... params)
List docker containers.
|
LogStream |
logs(String containerId,
DockerClient.LogsParameter... params)
Get docker container logs.
|
private String |
message(com.sun.jersey.api.client.ClientResponse response) |
private javax.ws.rs.core.MultivaluedMap<String,String> |
multivaluedMap(com.google.common.collect.Multimap<String,String> map) |
private RuntimeException |
propagate(String method,
com.sun.jersey.api.client.WebResource resource,
com.sun.jersey.api.client.ClientHandlerException e) |
private DockerRequestException |
propagate(String method,
com.sun.jersey.api.client.WebResource resource,
com.sun.jersey.api.client.UniformInterfaceException e) |
void |
pull(String image)
Pull a docker container image.
|
void |
removeContainer(String containerId)
Remove a docker container.
|
void |
removeContainer(String containerId,
boolean removeVolumes)
Remove a docker container.
|
List<RemovedImage> |
removeImage(String image)
Remove a docker image.
|
List<RemovedImage> |
removeImage(String image,
boolean force,
boolean noPrune)
Remove a docker image.
|
private <T> T |
request(String method,
Class<T> clazz,
com.sun.jersey.api.client.WebResource resource,
com.sun.jersey.api.client.UniformInterface request) |
private <T> T |
request(String method,
com.sun.jersey.api.client.GenericType<T> type,
com.sun.jersey.api.client.WebResource resource,
com.sun.jersey.api.client.WebResource.Builder request) |
private void |
request(String method,
com.sun.jersey.api.client.WebResource resource,
com.sun.jersey.api.client.UniformInterface request) |
private com.sun.jersey.api.client.WebResource |
resource() |
void |
startContainer(String containerId)
Start a docker container.
|
void |
startContainer(String containerId,
HostConfig hostConfig)
Start a docker container.
|
void |
tag(String image,
String name)
Tag a docker image.
|
Version |
version()
Get the docker version.
|
ContainerExit |
waitContainer(String containerId)
Wait for a docker container to exit.
|
private static final long CONNECT_TIMEOUT_MILLIS
private static final long READ_TIMEOUT_MILLIS
private static final org.slf4j.Logger log
private static final String VERSION
private static final com.sun.jersey.api.client.config.DefaultClientConfig CLIENT_CONFIG
private static final Pattern CONTAINER_NAME_PATTERN
private static final com.sun.jersey.api.client.GenericType<List<Container>> CONTAINER_LIST
private static final com.sun.jersey.api.client.GenericType<List<RemovedImage>> REMOVED_IMAGE_LIST
private final com.sun.jersey.api.client.Client client
private final URI uri
public DefaultDockerClient(String uri)
public DefaultDockerClient(URI uri)
public Version version() throws DockerException, InterruptedException
DockerClientversion in interface DockerClientDockerExceptionInterruptedExceptionpublic List<Container> listContainers(DockerClient.ListContainersParam... params) throws DockerException, InterruptedException
DockerClientlistContainers in interface DockerClientparams - Container listing and filtering options.DockerExceptionInterruptedExceptionpublic ContainerCreation createContainer(ContainerConfig config) throws DockerException, InterruptedException
DockerClientcreateContainer in interface DockerClientconfig - The container configuration.ImageNotFoundException - if the image was not found (404).DockerExceptionInterruptedExceptionpublic ContainerCreation createContainer(ContainerConfig config, String name) throws DockerException, InterruptedException
DockerClientcreateContainer in interface DockerClientconfig - The container configuration.name - The container name.ImageNotFoundException - if the image was not found (404).DockerExceptionInterruptedExceptionpublic void startContainer(String containerId) throws DockerException, InterruptedException
DockerClientstartContainer in interface DockerClientcontainerId - The id of the container to start.ContainerNotFoundException - if the container was not found (404).DockerExceptionInterruptedExceptionpublic void startContainer(String containerId, HostConfig hostConfig) throws DockerException, InterruptedException
DockerClientstartContainer in interface DockerClientcontainerId - The id of the container to start.hostConfig - The docker host configuration to use when starting the container.ContainerNotFoundException - if the container was not found (404).DockerExceptionInterruptedExceptionpublic void killContainer(String containerId) throws DockerException, InterruptedException
DockerClientkillContainer in interface DockerClientcontainerId - The id of the container to kill.ContainerNotFoundException - if the container was not found (404).DockerExceptionInterruptedExceptionpublic ContainerExit waitContainer(String containerId) throws DockerException, InterruptedException
DockerClientwaitContainer in interface DockerClientcontainerId - The id of the container to wait for.ContainerNotFoundException - if the container was not found (404).DockerExceptionInterruptedExceptionpublic void removeContainer(String containerId) throws DockerException, InterruptedException
DockerClientremoveContainer in interface DockerClientcontainerId - The id of the container to remove.ContainerNotFoundException - if the container was not found (404).DockerExceptionInterruptedExceptionpublic void removeContainer(String containerId, boolean removeVolumes) throws DockerException, InterruptedException
DockerClientremoveContainer in interface DockerClientcontainerId - The id of the container to remove.removeVolumes - Whether to remove volumes as well.ContainerNotFoundException - if the container was not found (404).DockerExceptionInterruptedExceptionpublic ContainerInfo inspectContainer(String containerId) throws DockerException, InterruptedException
DockerClientinspectContainer in interface DockerClientcontainerId - The id of the container to inspect.ContainerNotFoundException - if the container was not found (404).DockerExceptionInterruptedExceptionpublic void pull(String image) throws DockerException, InterruptedException
DockerClientpull in interface DockerClientimage - The image to pull.DockerExceptionInterruptedExceptionpublic void tag(String image, String name) throws DockerException, InterruptedException
DockerClienttag in interface DockerClientimage - The image to tag.name - The new name that will be applied to the image.DockerExceptionInterruptedExceptionpublic ImageInfo inspectImage(String image) throws DockerException, InterruptedException
DockerClientinspectImage in interface DockerClientimage - The image to inspect.ImageNotFoundException - if the image was not found (404).DockerExceptionInterruptedExceptionpublic List<RemovedImage> removeImage(String image) throws DockerException, InterruptedException
DockerClientremoveImage in interface DockerClientimage - The image to remove.ImageNotFoundException - if the image was not found (404).DockerExceptionInterruptedExceptionpublic List<RemovedImage> removeImage(String image, boolean force, boolean noPrune) throws DockerException, InterruptedException
DockerClientremoveImage in interface DockerClientimage - The image to remove.force - Force image removal.noPrune - Do not delete untagged parents.ImageNotFoundException - if the image was not found (404).DockerExceptionInterruptedExceptionpublic LogStream logs(String containerId, DockerClient.LogsParameter... params) throws DockerException, InterruptedException
DockerClientlogs in interface DockerClientcontainerId - The id of the container to get logs for.params - Params for controlling what streams to get and whether to tail or not.ContainerNotFoundException - if the container was not found (404).DockerExceptionInterruptedExceptionprivate com.sun.jersey.api.client.WebResource resource()
private <T> T request(String method, com.sun.jersey.api.client.GenericType<T> type, com.sun.jersey.api.client.WebResource resource, com.sun.jersey.api.client.WebResource.Builder request) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate <T> T request(String method, Class<T> clazz, com.sun.jersey.api.client.WebResource resource, com.sun.jersey.api.client.UniformInterface request) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate void request(String method, com.sun.jersey.api.client.WebResource resource, com.sun.jersey.api.client.UniformInterface request) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate DockerRequestException propagate(String method, com.sun.jersey.api.client.WebResource resource, com.sun.jersey.api.client.UniformInterfaceException e)
private RuntimeException propagate(String method, com.sun.jersey.api.client.WebResource resource, com.sun.jersey.api.client.ClientHandlerException e) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate String message(com.sun.jersey.api.client.ClientResponse response)
Copyright © 2014. All rights reserved.