public class DefaultDockerClient extends Object implements DockerClient, Closeable
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultDockerClient.Builder |
private static class |
DefaultDockerClient.LoadProgressHandler
Hack: this
ProgressHandler is meant to capture the image ID (or image digest in Docker
1.10+) of an image being loaded. |
DockerClient.AttachParameter, DockerClient.BuildParam, DockerClient.EventsFilterParam, DockerClient.EventsParam, DockerClient.ExecCreateParam, DockerClient.ExecStartParameter, DockerClient.ListContainersFilterParam, DockerClient.ListContainersParam, DockerClient.ListImagesFilterParam, DockerClient.ListImagesParam, DockerClient.LogsParam, DockerClient.RemoveContainerParam| Modifier and Type | Field and Description |
|---|---|
private String |
apiVersion |
private AuthConfig |
authConfig |
private javax.ws.rs.client.Client |
client |
private static javax.ws.rs.core.GenericType<List<Container>> |
CONTAINER_LIST |
private static Pattern |
CONTAINER_NAME_PATTERN |
private static com.google.common.base.Supplier<javax.ws.rs.client.ClientBuilder> |
DEFAULT_BUILDER_SUPPLIER |
private static org.glassfish.jersey.client.ClientConfig |
DEFAULT_CONFIG |
private static long |
DEFAULT_CONNECT_TIMEOUT_MILLIS |
private static int |
DEFAULT_CONNECTION_POOL_SIZE |
static String |
DEFAULT_HOST |
static int |
DEFAULT_PORT |
private static long |
DEFAULT_READ_TIMEOUT_MILLIS |
static String |
DEFAULT_UNIX_ENDPOINT |
private Map<String,Object> |
headers |
private static javax.ws.rs.core.GenericType<List<Image>> |
IMAGE_LIST |
private static javax.ws.rs.core.GenericType<List<ImageSearchResult>> |
IMAGES_SEARCH_RESULT_LIST |
private static org.slf4j.Logger |
log |
private static javax.ws.rs.core.GenericType<List<Network>> |
NETWORK_LIST |
static long |
NO_TIMEOUT |
private javax.ws.rs.client.Client |
noTimeoutClient |
private static javax.ws.rs.core.GenericType<List<RemovedImage>> |
REMOVED_IMAGE_LIST |
private static String |
UNIX_SCHEME |
private URI |
uri |
| Modifier | Constructor and Description |
|---|---|
protected |
DefaultDockerClient(DefaultDockerClient.Builder builder)
Create a new client using the configuration of the builder.
|
(package private) |
DefaultDockerClient(DefaultDockerClient.Builder builder,
com.google.common.base.Supplier<javax.ws.rs.client.ClientBuilder> clientBuilderSupplier) |
|
DefaultDockerClient(String uri)
Create a new client with default configuration.
|
|
DefaultDockerClient(URI uri)
Create a new client with default configuration.
|
|
DefaultDockerClient(URI uri,
DockerCertificates dockerCertificates)
Create a new client with default configuration.
|
| Modifier and Type | Method and Description |
|---|---|
LogStream |
attachContainer(String containerId,
DockerClient.AttachParameter... params)
Attach to the container id
|
int |
auth(AuthConfig authConfig)
Check auth configuration.
|
private String |
authHeader() |
private String |
authHeader(AuthConfig authConfig) |
private String |
authRegistryHeader(AuthRegistryConfig authRegistryConfig) |
String |
build(Path directory,
DockerClient.BuildParam... params)
Build a docker image.
|
String |
build(Path directory,
ProgressHandler handler,
DockerClient.BuildParam... params)
Build a docker image.
|
String |
build(Path directory,
String name,
DockerClient.BuildParam... params)
Build a docker image.
|
String |
build(Path directory,
String name,
ProgressHandler handler,
DockerClient.BuildParam... params)
Build a docker image.
|
String |
build(Path directory,
String name,
String dockerfile,
ProgressHandler handler,
DockerClient.BuildParam... params)
Build a docker image.
|
static DefaultDockerClient.Builder |
builder()
Create a new
DefaultDockerClient builder. |
void |
close()
Closes any and all underlying connections to docker, and release resources.
|
ContainerCreation |
commitContainer(String containerId,
String repo,
String tag,
ContainerConfig config,
String comment,
String author)
Create a new image from a container's changes.
|
void |
connectToNetwork(String containerId,
String networkId)
Connects a docker container to a network.
|
private void |
containerAction(String containerId,
String action) |
InputStream |
copyContainer(String containerId,
String path)
Copies some files out of a container.
|
void |
copyToContainer(Path directory,
String containerId,
String path)
Copies some files from host to container.
|
ContainerCreation |
createContainer(ContainerConfig config)
Create a docker container.
|
ContainerCreation |
createContainer(ContainerConfig config,
String name)
Create a docker container.
|
NetworkCreation |
createNetwork(NetworkConfig networkConfig)
Create a new network
|
private static String |
defaultCertPath() |
private static String |
defaultEndpoint() |
void |
disconnectFromNetwork(String containerId,
String networkId)
Disconnects a docker container to a network.
|
EventStream |
events(DockerClient.EventsParam... params)
Watches the docker API for events.
|
String |
execCreate(String containerId,
String[] cmd,
DockerClient.ExecCreateParam... params)
Sets up an exec instance in a running container id.
|
ExecState |
execInspect(String execId)
Inspects a running or previously run exec instance id.
|
LogStream |
execStart(String execId,
DockerClient.ExecStartParameter... params)
Starts a previously set up exec instance id.
|
InputStream |
exportContainer(String containerId)
Export a docker container as a tar archive.
|
static DefaultDockerClient.Builder |
fromEnv()
Create a new
DefaultDockerClient builder prepopulated with values loaded from the
DOCKER_HOST and DOCKER_CERT_PATH environment variables. |
(package private) javax.ws.rs.client.Client |
getClient() |
private org.apache.http.impl.conn.PoolingHttpClientConnectionManager |
getConnectionManager(DefaultDockerClient.Builder builder) |
String |
getHost()
Get the Docker host address
|
private LogStream |
getLogStream(String method,
javax.ws.rs.client.WebTarget resource,
String containerId) |
(package private) javax.ws.rs.client.Client |
getNoTimeoutClient() |
private org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> |
getSchemeRegistry(DefaultDockerClient.Builder builder) |
private javax.ws.rs.client.Invocation.Builder |
headers(javax.ws.rs.client.Invocation.Builder request) |
Info |
info()
Get docker instance information.
|
ContainerInfo |
inspectContainer(String containerId)
Inspect a docker container.
|
ImageInfo |
inspectImage(String image)
Inspect a docker container image.
|
Network |
inspectNetwork(String networkId)
Inspect a specific network
|
void |
killContainer(String containerId)
Kill a docker container.
|
List<Container> |
listContainers(DockerClient.ListContainersParam... params)
List docker containers.
|
List<Image> |
listImages(DockerClient.ListImagesParam... params)
List docker images.
|
List<Network> |
listNetworks()
List all networks
|
void |
load(String image,
InputStream imagePayload)
Loads an image (the given input stream is closed internally).
|
void |
load(String image,
InputStream imagePayload,
AuthConfig authConfig)
Loads an image (the given input stream is closed internally).
|
void |
load(String image,
InputStream imagePayload,
AuthConfig authConfig,
ProgressHandler handler)
Loads an image (the given input stream is closed internally).
|
void |
load(String image,
InputStream imagePayload,
ProgressHandler handler)
Loads an image (the given input stream is closed internally).
|
LogStream |
logs(String containerId,
DockerClient.LogsParam... params)
Get docker container logs.
|
private void |
manageNetworkConnection(String containerId,
String methodname,
String networkId) |
private String |
message(javax.ws.rs.core.Response response) |
private javax.ws.rs.client.WebTarget |
noTimeoutResource() |
void |
pauseContainer(String containerId)
Pause a docker container.
|
String |
ping()
Ping the docker daemon.
|
private RuntimeException |
propagate(String method,
javax.ws.rs.client.WebTarget resource,
Exception e) |
void |
pull(String image)
Pull a docker container image.
|
void |
pull(String image,
AuthConfig authConfig)
Pull a private docker container image.
|
void |
pull(String image,
AuthConfig authConfig,
ProgressHandler handler)
Pull a private docker container image, using a custom ProgressMessageHandler.
|
void |
pull(String image,
ProgressHandler handler)
Pull a docker container image, using a custom ProgressMessageHandler
|
void |
push(String image)
Push a docker container image.
|
void |
push(String image,
ProgressHandler handler)
Push a docker container image, using a custom ProgressHandler
|
void |
removeContainer(String containerId)
Remove a docker container.
|
void |
removeContainer(String containerId,
boolean removeVolumes)
Deprecated.
|
void |
removeContainer(String containerId,
DockerClient.RemoveContainerParam... params)
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.
|
void |
removeNetwork(String networkId)
Remove a docker network.
|
void |
renameContainer(String containerId,
String name)
Rename a docker container.
|
private <T> T |
request(String method,
Class<T> clazz,
javax.ws.rs.client.WebTarget resource,
javax.ws.rs.client.Invocation.Builder request) |
private <T> T |
request(String method,
Class<T> clazz,
javax.ws.rs.client.WebTarget resource,
javax.ws.rs.client.Invocation.Builder request,
javax.ws.rs.client.Entity<?> entity) |
private <T> T |
request(String method,
javax.ws.rs.core.GenericType<T> type,
javax.ws.rs.client.WebTarget resource,
javax.ws.rs.client.Invocation.Builder request) |
private void |
request(String method,
javax.ws.rs.client.WebTarget resource,
javax.ws.rs.client.Invocation.Builder request) |
private javax.ws.rs.client.WebTarget |
resource() |
void |
restartContainer(String containerId)
Restart a docker container.
|
void |
restartContainer(String containerId,
int secondsToWaitBeforeRestart)
Restart a docker container.
|
InputStream |
save(String image) |
InputStream |
save(String image,
AuthConfig authConfig) |
List<ImageSearchResult> |
searchImages(String term)
Search for images on Docker Hub
This method is broken for Docker 1.7.x because of a Docker bug.
|
void |
startContainer(String containerId)
Start a docker container.
|
ContainerStats |
stats(String containerId)
Retrieves one-time stats (stream=0) for the container with the specified id.
|
void |
stopContainer(String containerId,
int secondsToWaitBeforeKilling)
Stop a docker container by sending a SIGTERM, and following up with a SIGKILL if the container
doesn't exit gracefully and in a timely manner.
|
void |
tag(String image,
String name)
Tag a docker image.
|
void |
tag(String image,
String name,
boolean force)
Tag a docker image.
|
void |
unpauseContainer(String containerId)
Unpause a docker container.
|
private String |
urlEncode(String unencoded)
URL-encodes a string
|
private String |
urlEncodeFilters(Map<String,List<String>> filters)
Takes a map of filters and URL-encodes them.
|
Version |
version()
Get the docker version.
|
ContainerExit |
waitContainer(String containerId)
Wait for a docker container to exit.
|
public static final String DEFAULT_UNIX_ENDPOINT
public static final String DEFAULT_HOST
public static final int DEFAULT_PORT
private static final String UNIX_SCHEME
private static final org.slf4j.Logger log
public static final long NO_TIMEOUT
private static final long DEFAULT_CONNECT_TIMEOUT_MILLIS
private static final long DEFAULT_READ_TIMEOUT_MILLIS
private static final int DEFAULT_CONNECTION_POOL_SIZE
private static final org.glassfish.jersey.client.ClientConfig DEFAULT_CONFIG
private static final Pattern CONTAINER_NAME_PATTERN
private static final javax.ws.rs.core.GenericType<List<ImageSearchResult>> IMAGES_SEARCH_RESULT_LIST
private static final javax.ws.rs.core.GenericType<List<RemovedImage>> REMOVED_IMAGE_LIST
private static final com.google.common.base.Supplier<javax.ws.rs.client.ClientBuilder> DEFAULT_BUILDER_SUPPLIER
private final javax.ws.rs.client.Client client
private final javax.ws.rs.client.Client noTimeoutClient
private final URI uri
private final String apiVersion
private final AuthConfig authConfig
public DefaultDockerClient(String uri)
uri - The docker rest api uri.public DefaultDockerClient(URI uri)
uri - The docker rest api uri.public DefaultDockerClient(URI uri, DockerCertificates dockerCertificates)
uri - The docker rest api uri.dockerCertificates - The certificates to use for HTTPS.protected DefaultDockerClient(DefaultDockerClient.Builder builder)
builder - DefaultDockerClient builderDefaultDockerClient(DefaultDockerClient.Builder builder, com.google.common.base.Supplier<javax.ws.rs.client.ClientBuilder> clientBuilderSupplier)
javax.ws.rs.client.Client getClient()
javax.ws.rs.client.Client getNoTimeoutClient()
public String getHost()
DockerClientgetHost in interface DockerClientprivate org.apache.http.impl.conn.PoolingHttpClientConnectionManager getConnectionManager(DefaultDockerClient.Builder builder)
private org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> getSchemeRegistry(DefaultDockerClient.Builder builder)
public void close()
DockerClientclose in interface DockerClientclose in interface Closeableclose in interface AutoCloseablepublic String ping() throws DockerException, InterruptedException
DockerClientping in interface DockerClientDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic Version version() throws DockerException, InterruptedException
DockerClientversion in interface DockerClientDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic int auth(AuthConfig authConfig) throws DockerException, InterruptedException
DockerClientauth in interface DockerClientauthConfig - The authentication config needed to pull the image.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic Info info() throws DockerException, InterruptedException
DockerClientinfo in interface DockerClientDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic List<Container> listContainers(DockerClient.ListContainersParam... params) throws DockerException, InterruptedException
DockerClientlistContainers in interface DockerClientparams - Container listing and filtering options.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedprivate String urlEncode(String unencoded) throws DockerException
unencoded - A string that may contain characters not allowed in URLsDockerException - if there's an UnsupportedEncodingExceptionprivate String urlEncodeFilters(Map<String,List<String>> filters) throws DockerException
filters - A map of filters.DockerException - if there's an IOExceptionpublic List<Image> listImages(DockerClient.ListImagesParam... params) throws DockerException, InterruptedException
DockerClientlistImages in interface DockerClientparams - Image listing and filtering options.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic ContainerCreation createContainer(ContainerConfig config) throws DockerException, InterruptedException
DockerClientcreateContainer in interface DockerClientconfig - The container configuration.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic ContainerCreation createContainer(ContainerConfig config, String name) throws DockerException, InterruptedException
DockerClientcreateContainer in interface DockerClientconfig - The container configuration.name - The container name.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void startContainer(String containerId) throws DockerException, InterruptedException
DockerClientstartContainer in interface DockerClientcontainerId - The id of the container to start.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedprivate void containerAction(String containerId, String action) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionpublic void pauseContainer(String containerId) throws DockerException, InterruptedException
DockerClientpauseContainer in interface DockerClientcontainerId - The id of the container to pause.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void unpauseContainer(String containerId) throws DockerException, InterruptedException
DockerClientunpauseContainer in interface DockerClientcontainerId - The id of the container to pause.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void restartContainer(String containerId) throws DockerException, InterruptedException
DockerClientrestartContainer in interface DockerClientcontainerId - The id of the container to restart.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void restartContainer(String containerId, int secondsToWaitBeforeRestart) throws DockerException, InterruptedException
DockerClientrestartContainer in interface DockerClientcontainerId - The id of the container to restart.secondsToWaitBeforeRestart - number of seconds to wait before killing the container.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void killContainer(String containerId) throws DockerException, InterruptedException
DockerClientkillContainer in interface DockerClientcontainerId - The id of the container to kill.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void stopContainer(String containerId, int secondsToWaitBeforeKilling) throws DockerException, InterruptedException
DockerClientstopContainer in interface DockerClientcontainerId - The id of the container to stop.secondsToWaitBeforeKilling - Time to wait after SIGTERM before sending SIGKILL.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic ContainerExit waitContainer(String containerId) throws DockerException, InterruptedException
DockerClientwaitContainer in interface DockerClientcontainerId - The id of the container to wait for.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void removeContainer(String containerId) throws DockerException, InterruptedException
DockerClientremoveContainer in interface DockerClientcontainerId - The id of the container to remove.DockerException - If a server error occurred (500)InterruptedException - If the thread is interrupted@Deprecated public 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.DockerException - If a server error occurred (500)InterruptedException - If the thread is interruptedpublic void removeContainer(String containerId, DockerClient.RemoveContainerParam... params) throws DockerException, InterruptedException
DockerClientremoveContainer in interface DockerClientcontainerId - The id of the container to remove.params - DockerClient.RemoveContainerParamDockerException - If a server error occurred (500)InterruptedException - If the thread is interruptedpublic InputStream exportContainer(String containerId) throws DockerException, InterruptedException
DockerClientexportContainer in interface DockerClientcontainerId - The id of the container to export.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic InputStream copyContainer(String containerId, String path) throws DockerException, InterruptedException
DockerClientcopyContainer in interface DockerClientcontainerId - The id of the container to copy files from.path - The path inside of the container to copy. If this is a directory, it will
be copied recursively. If this is a file, only that file will be copied.copy(..., "/usr/share") will
result in a directory called share in the tar archive). The directory name is
completely resolved, so copying "/usr/share/././." will still create a directory called
"share" in the tar archive. If a single file was copied, that file will be the sole
entry in the tar archive. Copying "." or equivalently "/" will result in the
tar archive containing a single folder named after the container ID.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void copyToContainer(Path directory, String containerId, String path) throws DockerException, InterruptedException, IOException
DockerClientcopyToContainer in interface DockerClientdirectory - The path to sent to containercontainerId - The id of the container to sent files.path - The path inside of the container to put files.DockerException - If a server error occurred (500)InterruptedException - If the thread is interruptedIOException - If IOExceptionpublic ContainerInfo inspectContainer(String containerId) throws DockerException, InterruptedException
DockerClientinspectContainer in interface DockerClientcontainerId - The id of the container to inspect.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic ContainerCreation commitContainer(String containerId, String repo, String tag, ContainerConfig config, String comment, String author) throws DockerException, InterruptedException
DockerClientcommitContainer in interface DockerClientcontainerId - The id of the container to commit.repo - repository to commit to.tag - image tag.config - ContainerConfig to commit.comment - commit message.author - image author.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void renameContainer(String containerId, String name) throws DockerException, InterruptedException
DockerClientrenameContainer in interface DockerClientcontainerId - The id of the container to rename.name - The new name the container will haveDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic List<ImageSearchResult> searchImages(String term) throws DockerException, InterruptedException
DockerClientsearchImages in interface DockerClientterm - the search termDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void load(String image, InputStream imagePayload) throws DockerException, InterruptedException
DockerClientload in interface DockerClientimage - the name to assign to the image.imagePayload - the image's payload (i.e.: the stream corresponding to the image's .tar
file).DockerException - if a server error occurred (500).InterruptedException - if the thread is interrupted.public void load(String image, InputStream imagePayload, AuthConfig authConfig, ProgressHandler handler) throws DockerException, InterruptedException
DockerClientload in interface DockerClientimage - the name to assign to the image.imagePayload - the image's payload (i.e.: the stream corresponding to the image's .tar
file).authConfig - The authentication config needed to pull the image.handler - The handler to use for processing each progress message received from
Docker.DockerException - if a server error occurred (500).InterruptedException - if the thread is interrupted.public void load(String image, InputStream imagePayload, AuthConfig authConfig) throws DockerException, InterruptedException
DockerClientload in interface DockerClientimage - the name to assign to the image.imagePayload - the image's payload (i.e.: the stream corresponding to the image's .tar
file).authConfig - The authentication config needed to pull the image.DockerException - if a server error occurred (500).InterruptedException - if the thread is interrupted.public void load(String image, InputStream imagePayload, ProgressHandler handler) throws DockerException, InterruptedException
DockerClientload in interface DockerClientimage - the name to assign to the image.imagePayload - the image's payload (i.e.: the stream corresponding to the image's .tar
file).handler - The handler to use for processing each progress message received from
Docker.DockerException - if a server error occurred (500).InterruptedException - if the thread is interrupted.public InputStream save(String image) throws DockerException, IOException, InterruptedException
save in interface DockerClientimage - the name of the image to save.DockerException - if a server error occurred (500).IOException - if the server started returning, but an I/O error occurred in the
context of processing it on the client-side.InterruptedException - if the thread is interrupted.public InputStream save(String image, AuthConfig authConfig) throws DockerException, IOException, InterruptedException
save in interface DockerClientimage - the name of the image to save.authConfig - The authentication config needed to pull the image.DockerException - if a server error occurred (500).IOException - if the server started returning, but an I/O error occurred in the
context of processing it on the client-side.InterruptedException - if the thread is interrupted.public void pull(String image) throws DockerException, InterruptedException
DockerClientpull in interface DockerClientimage - The image to pull.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void pull(String image, ProgressHandler handler) throws DockerException, InterruptedException
DockerClientpull in interface DockerClientimage - The image to pull.handler - The handler to use for processing each progress message received from Docker.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void pull(String image, AuthConfig authConfig) throws DockerException, InterruptedException
DockerClientpull in interface DockerClientimage - The image to pull.authConfig - The authentication config needed to pull the image.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void pull(String image, AuthConfig authConfig, ProgressHandler handler) throws DockerException, InterruptedException
DockerClientpull in interface DockerClientimage - The image to pull.authConfig - The authentication config needed to pull the image.handler - The handler to use for processing each progress message received from
Docker.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void push(String image) throws DockerException, InterruptedException
DockerClientpush in interface DockerClientimage - The image to push.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void push(String image, ProgressHandler handler) throws DockerException, InterruptedException
DockerClientpush in interface DockerClientimage - The image to push.handler - The handler to use for processing each progress message received from Docker.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic 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.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void tag(String image, String name, boolean force) throws DockerException, InterruptedException
DockerClienttag in interface DockerClientimage - The image to tag.name - The new name that will be applied to the image.force - Whether to force the tagging even if the tag is already assigned to another
image.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic String build(Path directory, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException
DockerClientbuild in interface DockerClientdirectory - The directory containing the dockerfile.params - Additional flags to use during build.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedIOException - If some IO shit happened.public String build(Path directory, String name, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException
DockerClientbuild in interface DockerClientdirectory - The directory containing the dockerfile.name - The repository name and optional tag to apply to the built image.params - Additional flags to use during build.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedIOException - If some IO shit happened.public String build(Path directory, ProgressHandler handler, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException
DockerClientbuild in interface DockerClientdirectory - The directory containing the dockerfile.handler - The handler to use for processing each progress message received from Docker.params - Additional flags to use during build.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedIOException - If some IO shit happened.public String build(Path directory, String name, ProgressHandler handler, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException
DockerClientbuild in interface DockerClientdirectory - The directory containing the dockerfile.name - The repository name and optional tag to apply to the built image.handler - The handler to use for processing each progress message received from Docker.params - Additional flags to use during build.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedIOException - If some IO shit happened.public String build(Path directory, String name, String dockerfile, ProgressHandler handler, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException
DockerClientbuild in interface DockerClientdirectory - The directory containing the dockerfile.name - The repository name and optional tag to apply to the built image.dockerfile - The path within the build context to the Dockerfilehandler - The handler to use for processing each progress message received from
Docker.params - Additional flags to use during build.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedIOException - If some IO shit happened.public ImageInfo inspectImage(String image) throws DockerException, InterruptedException
DockerClientinspectImage in interface DockerClientimage - The image to inspect.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic List<RemovedImage> removeImage(String image) throws DockerException, InterruptedException
DockerClientremoveImage in interface DockerClientimage - The image to remove.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic 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.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic LogStream logs(String containerId, DockerClient.LogsParam... 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.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic EventStream events(DockerClient.EventsParam... params) throws DockerException, InterruptedException
DockerClientevents in interface DockerClientparams - The parameters to apply to the events requestDockerException - If a server error occurred (500)InterruptedException - If the thread is interruptedpublic LogStream attachContainer(String containerId, DockerClient.AttachParameter... params) throws DockerException, InterruptedException
DockerClientattachContainer 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).DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedprivate LogStream getLogStream(String method, javax.ws.rs.client.WebTarget resource, String containerId) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionpublic String execCreate(String containerId, String[] cmd, DockerClient.ExecCreateParam... params) throws DockerException, InterruptedException
DockerClientexecCreate in interface DockerClientcontainerId - The id of the containercmd - shell commandparams - Exec paramsDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic LogStream execStart(String execId, DockerClient.ExecStartParameter... params) throws DockerException, InterruptedException
DockerClientexecStart in interface DockerClientexecId - exec idparams - Exec start paramsDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic ExecState execInspect(String execId) throws DockerException, InterruptedException
DockerClientexecInspect in interface DockerClientexecId - exec idDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic ContainerStats stats(String containerId) throws DockerException, InterruptedException
DockerClientstats in interface DockerClientcontainerId - The id of the container to retrieve stats for.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic List<Network> listNetworks() throws DockerException, InterruptedException
DockerClientlistNetworks in interface DockerClientDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic Network inspectNetwork(String networkId) throws DockerException, InterruptedException
DockerClientinspectNetwork in interface DockerClientnetworkId - The id of the networkDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic NetworkCreation createNetwork(NetworkConfig networkConfig) throws DockerException, InterruptedException
DockerClientcreateNetwork in interface DockerClientnetworkConfig - The network creation parametersDockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void removeNetwork(String networkId) throws DockerException, InterruptedException
DockerClientremoveNetwork in interface DockerClientnetworkId - The id of the network to remove.DockerException - if a server error occurred (500)InterruptedException - If the thread is interruptedpublic void connectToNetwork(String containerId, String networkId) throws DockerException, InterruptedException
DockerClientconnectToNetwork in interface DockerClientcontainerId - The id of the container to connect.networkId - The id of the network to connect.DockerException - if a server error occurred (500)ContainerNotFoundException - if the container was not found (404)InterruptedException - If the thread is interruptedpublic void disconnectFromNetwork(String containerId, String networkId) throws DockerException, InterruptedException
DockerClientdisconnectFromNetwork in interface DockerClientcontainerId - The id of the container to disconnect.networkId - The id of the network to disconnect.DockerException - if a server error occurred (500)ContainerNotFoundException - if the container was not found (404)InterruptedException - If the thread is interruptedprivate void manageNetworkConnection(String containerId, String methodname, String networkId) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate javax.ws.rs.client.WebTarget resource()
private javax.ws.rs.client.WebTarget noTimeoutResource()
private <T> T request(String method, javax.ws.rs.core.GenericType<T> type, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate <T> T request(String method, Class<T> clazz, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate <T> T request(String method, Class<T> clazz, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request, javax.ws.rs.client.Entity<?> entity) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate void request(String method, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate javax.ws.rs.client.Invocation.Builder headers(javax.ws.rs.client.Invocation.Builder request)
private RuntimeException propagate(String method, javax.ws.rs.client.WebTarget resource, Exception e) throws DockerException, InterruptedException
DockerExceptionInterruptedExceptionprivate String message(javax.ws.rs.core.Response response)
private String authHeader() throws DockerException
DockerExceptionprivate String authHeader(AuthConfig authConfig) throws DockerException
DockerExceptionprivate String authRegistryHeader(AuthRegistryConfig authRegistryConfig) throws DockerException
DockerExceptionpublic static DefaultDockerClient.Builder builder()
DefaultDockerClient builder.public static DefaultDockerClient.Builder fromEnv() throws DockerCertificateException
DefaultDockerClient builder prepopulated with values loaded from the
DOCKER_HOST and DOCKER_CERT_PATH environment variables.DockerCertificateException - if we could not build a DockerCertificates objectprivate static String defaultEndpoint()
private static String defaultCertPath()
Copyright © 2016. All rights reserved.