Package com.spotify.docker.client
Class DefaultDockerClient
java.lang.Object
com.spotify.docker.client.DefaultDockerClient
- All Implemented Interfaces:
DockerClient,Closeable,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprivate static classHack: thisProgressHandleris meant to capture the image ID of an image being built.private static classHack: thisProgressHandleris meant to capture the image ID (or image digest in Docker 1.10+) of an image being created.private static classHack: thisProgressHandleris meant to capture the image names of an image being loaded.private static classNested classes/interfaces inherited from interface com.spotify.docker.client.DockerClient
DockerClient.AttachParameter, DockerClient.BuildParam, DockerClient.EventsFilterParam, DockerClient.EventsParam, DockerClient.ExecCreateParam, DockerClient.ExecStartParameter, DockerClient.FilterParam, DockerClient.ListContainersFilterParam, DockerClient.ListContainersParam, DockerClient.ListImagesFilterParam, DockerClient.ListImagesParam, DockerClient.ListNetworksFilterParam, DockerClient.ListNetworksParam, DockerClient.ListVolumesFilterParam, DockerClient.ListVolumesParam, DockerClient.LogsParam, DockerClient.Param, DockerClient.RemoveContainerParam, DockerClient.Signal -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final javax.ws.rs.client.Clientprivate static final javax.ws.rs.core.GenericType<List<ContainerChange>> private static final Patternprivate static final longprivate static final intprivate static final longprivate final org.glassfish.jersey.client.ClientConfigprivate static final javax.ws.rs.core.GenericType<Distribution> private static final javax.ws.rs.core.GenericType<List<ImageHistory>> private static final javax.ws.rs.core.GenericType<List<ImageSearchResult>> private static final org.slf4j.Logger(package private) static final longprivate final javax.ws.rs.client.Clientprivate final RegistryAuthSupplierprivate static final javax.ws.rs.core.GenericType<List<RemovedImage>> private static final Stringprivate final URI -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate a new client using the configuration of the builder.Create a new client with default configuration.DefaultDockerClient(URI uri) Create a new client with default configuration.DefaultDockerClient(URI uri, DockerCertificatesStore dockerCertificatesStore) Create a new client with default configuration. -
Method Summary
Modifier and TypeMethodDescriptionprivate javax.ws.rs.client.WebTargetaddParameters(javax.ws.rs.client.WebTarget resource, DockerClient.Param... params) archiveContainer(String containerId, String path) Copies an archive out of a container.private voidassertApiVersionIsAbove(String minimumVersion) attachContainer(String containerId, DockerClient.AttachParameter... params) Attach to the container id.intauth(RegistryAuth registryAuth) Check auth configuration.private StringauthHeader(RegistryAuth registryAuth) private StringauthRegistryHeader(RegistryConfigs registryConfigs) build(Path directory, DockerClient.BuildParam... params) Build a docker image.build(Path directory, ProgressHandler handler, DockerClient.BuildParam... params) Build a docker image.build(Path directory, String name, DockerClient.BuildParam... params) Build a docker image.build(Path directory, String name, ProgressHandler handler, DockerClient.BuildParam... params) Build a docker image.build(Path directory, String name, String dockerfile, ProgressHandler handler, DockerClient.BuildParam... params) Build a docker image.static DefaultDockerClient.Builderbuilder()Create a newDefaultDockerClientbuilder.private voidcheckTtyParams(Integer height, Integer width) voidclose()Closes any and all underlying connections to docker, and release resources.commitContainer(String containerId, String repo, String tag, ContainerConfig config, String comment, String author) Create a new image from a container's changes.voidconnectToNetwork(String networkId, NetworkConnection networkConnection) Connects a docker container to a network, with extended configuration.voidconnectToNetwork(String containerId, String networkId) Connects a docker container to a network.private voidcontainerAction(String containerId, String action) private voidcontainerAction(String containerId, String action, javax.ws.rs.core.MultivaluedMap<String, String> queryParameters) copyContainer(String containerId, String path) Deprecated.voidcopyToContainer(InputStream tarStream, String containerId, String path) voidcopyToContainer(Path directory, String containerId, String path) Copies some files from host to container.voidcreate(String image, InputStream imagePayload) Creates a single image from a tarball.voidcreate(String image, InputStream imagePayload, ProgressHandler handler) Creates a single image from a tarball.createConfig(ConfigSpec config) Create a config.createContainer(ContainerConfig config) Create a docker container.createContainer(ContainerConfig config, String name) Create a docker container.createNetwork(NetworkConfig networkConfig) Create a new network.createSecret(SecretSpec secret) Create a secret.createService(ServiceSpec spec) Create a new service.createService(ServiceSpec spec, RegistryAuth config) Create a new service.createVolume(Volume volume) voiddeleteConfig(String configId) Delete a config.voiddeleteNode(String nodeId) Remove a node from the swarm.voiddeleteNode(String nodeId, boolean force) Remove a node from the swarm.voiddeleteSecret(String secretId) Delete a secret.voiddisconnectFromNetwork(String containerId, String networkId) Disconnects a docker container to a network.voiddisconnectFromNetwork(String containerId, String networkId, boolean force) Disconnects a docker container to a network.events(DockerClient.EventsParam... params) Watches the docker API for events.execCreate(String containerId, String[] cmd, DockerClient.ExecCreateParam... params) Sets up an exec instance in a running container id.execInspect(String execId) Inspects a running or previously run exec instance id.voidexecResizeTty(String execId, Integer height, Integer width) Resizes the tty session used by an exec command.execStart(String execId, DockerClient.ExecStartParameter... params) Starts a previously set up exec instance id.exportContainer(String containerId) Export a docker container as a tar archive.static DefaultDockerClient.BuilderfromEnv()Create a newDefaultDockerClientbuilder prepopulated with values loaded from the DOCKER_HOST and DOCKER_CERT_PATH environment variables.(package private) javax.ws.rs.client.Clientprivate org.apache.http.impl.conn.PoolingHttpClientConnectionManagergetDistribution(String imageName) Get the distribution of a container.getHost()Get the Docker host address.private LogStreamgetLogStream(String method, javax.ws.rs.client.WebTarget resource, String containerId) (package private) javax.ws.rs.client.ClientgetQueryParamMap(javax.ws.rs.client.WebTarget resource) private org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> private LogStreamgetServiceLogStream(String method, javax.ws.rs.client.WebTarget resource, String serviceId) private javax.ws.rs.client.Invocation.Builderheaders(javax.ws.rs.client.Invocation.Builder request) Return the history of the image.info()Get docker instance information.Initialize a new swarm.inspectConfig(String configId) Inspect a config.inspectContainer(String containerId) Inspect a docker container.inspectContainerChanges(String containerId) Inspect changes on a container's filesystem.inspectImage(String image) Inspect a docker container image.inspectNetwork(String networkId) Inspect a specific network.inspectNode(String nodeId) Inspects a swarm node.inspectSecret(String secretId) Inspect a secret.inspectService(String serviceId) Inspect an existing service.Inspect the swarm.inspectTask(String taskId) Inspect an existing task.inspectVolume(String volumeName) voidJoin an existing swarm.voidkillContainer(String containerId) Kill a docker container.voidkillContainer(String containerId, DockerClient.Signal signal) Kill a docker container.voidLeave a swarm.voidleaveSwarm(boolean force) Leave a swarm forcefully.List swarm configs.listConfigs(Config.Criteria criteria) List swarm configs.listContainers(DockerClient.ListContainersParam... params) List docker containers.listImages(DockerClient.ListImagesParam... params) List docker images.listNetworks(DockerClient.ListNetworksParam... params) List all or a subset of the networks.List swarm nodes.listNodes(Node.Criteria criteria) List swarm nodes that match the given criteria.List secrets.List all services.listServices(Service.Criteria criteria) List services that match the given criteria.List all tasks.listTasks(Task.Criteria criteria) List tasks that match the given criteria.listVolumes(DockerClient.ListVolumesParam... params) load(InputStream imagePayload) Load a set of images and tags from a tarball.load(InputStream imagePayload, ProgressHandler handler) Load a set of images and tags from a tarball, using a custom ProgressMessageHandler.voidload(String image, InputStream imagePayload) Deprecated.voidload(String image, InputStream imagePayload, ProgressHandler handler) Deprecated.logs(String containerId, DockerClient.LogsParam... params) Get docker container logs.private Stringmessage(javax.ws.rs.core.Response response) private javax.ws.rs.client.WebTargetvoidpauseContainer(String containerId) Pause a docker container.ping()Ping the docker daemon.private RuntimeExceptionvoidPull a docker container image.voidpull(String image, RegistryAuth registryAuth) Pull a private docker container image.voidpull(String image, RegistryAuth registryAuth, ProgressHandler handler) Pull a private docker container image, using a custom ProgressMessageHandler.voidpull(String image, ProgressHandler handler) Pull a docker container image, using a custom ProgressMessageHandlervoidPush a docker container image.voidpush(String image, RegistryAuth registryAuth) voidpush(String image, ProgressHandler handler) Push a docker container image, using a custom ProgressHandlervoidpush(String image, ProgressHandler handler, RegistryAuth registryAuth) voidremoveContainer(String containerId) Remove a docker container.voidremoveContainer(String containerId, boolean removeVolumes) Deprecated.voidremoveContainer(String containerId, DockerClient.RemoveContainerParam... params) Remove a docker container.removeImage(String image) Remove a docker image.removeImage(String image, boolean force, boolean noPrune) Remove a docker image.voidremoveNetwork(String networkId) Remove a docker network.voidremoveService(String serviceId) Remove an existing service.voidremoveVolume(Volume volume) voidremoveVolume(String volumeName) voidrenameContainer(String containerId, String name) Rename a docker container.private <T> Trequest(String method, Class<T> clazz, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) private <T> Trequest(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 voidrequest(String method, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) private <T> Trequest(String method, javax.ws.rs.core.GenericType<T> type, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) private voidrequestAndTail(String method, ProgressHandler handler, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) private voidrequestAndTail(String method, ProgressHandler handler, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request, javax.ws.rs.client.Entity<?> entity) voidResize container TTY This API is valid only ifttywas specified as part ofcreatingthe container.private javax.ws.rs.client.WebTargetresource()voidrestartContainer(String containerId) Restart a docker container.voidrestartContainer(String containerId, int secondsToWaitBeforeRestart) Restart a docker container.Get a tarball containing all images and metadata for the repository specified.saveMultiple(String... images) Get a tarball containing all images and metadata for one or more repositories.searchImages(String term) Search for images on Docker HubserviceLogs(String serviceId, DockerClient.LogsParam... params) Get docker service logs.voidstartContainer(String containerId) Start a docker container.Retrieves one-time stats (stream=0) for the container with the specified id.voidstopContainer(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.voidTag a docker image.voidTag a docker image.private voidtailResponse(String method, javax.ws.rs.core.Response response, ProgressHandler handler, javax.ws.rs.client.WebTarget resource) topContainer(String containerId) List processes running inside the container by usingps.topContainer(String containerId, String psArgs) List processes running inside the container usingpsand the given arguments.private StringvoidUnlock a swarm.Get an unlock key for unlocking a swarm.voidunpauseContainer(String containerId) Unpause a docker container.voidupdateConfig(String configId, Long version, ConfigSpec nodeSpec) Update a swarm config.updateContainer(String containerId, HostConfig config) Update an existing container.voidupdateNode(String nodeId, Long version, NodeSpec nodeSpec) Update a swarm node.private org.glassfish.jersey.client.ClientConfigupdateProxy(org.glassfish.jersey.client.ClientConfig config, DefaultDockerClient.Builder builder) voidupdateService(String serviceId, Long version, ServiceSpec spec) Update an existing service.voidupdateService(String serviceId, Long version, ServiceSpec spec, RegistryAuth config) Update an existing service.voidupdateSwarm(Long version, boolean rotateWorkerToken, boolean rotateManagerToken, boolean rotateManagerUnlockKey, SwarmSpec spec) Update a swarm.voidupdateSwarm(Long version, boolean rotateWorkerToken, boolean rotateManagerToken, SwarmSpec spec) Update a swarm.voidupdateSwarm(Long version, boolean rotateWorkerToken, SwarmSpec spec) Update a swarm.voidupdateSwarm(Long version, SwarmSpec spec) Update a swarm.private StringURL-encodes a string when used as a URL query parameter's value.private StringurlEncodeFilters(Map<String, List<String>> filters) Takes a map of filters and URL-encodes them.version()Get the docker version.waitContainer(String containerId) Wait for a docker container to exit.
-
Field Details
-
UNIX_SCHEME
- See Also:
-
log
private static final org.slf4j.Logger log -
NO_TIMEOUT
static final long NO_TIMEOUT- See Also:
-
DEFAULT_CONNECT_TIMEOUT_MILLIS
private static final long DEFAULT_CONNECT_TIMEOUT_MILLIS -
DEFAULT_READ_TIMEOUT_MILLIS
private static final long DEFAULT_READ_TIMEOUT_MILLIS -
DEFAULT_CONNECTION_POOL_SIZE
private static final int DEFAULT_CONNECTION_POOL_SIZE- See Also:
-
defaultConfig
private final org.glassfish.jersey.client.ClientConfig defaultConfig -
CONTAINER_NAME_PATTERN
-
CONTAINER_LIST
-
CONTAINER_CHANGE_LIST
-
IMAGE_LIST
-
NETWORK_LIST
-
IMAGES_SEARCH_RESULT_LIST
private static final javax.ws.rs.core.GenericType<List<ImageSearchResult>> IMAGES_SEARCH_RESULT_LIST -
REMOVED_IMAGE_LIST
-
IMAGE_HISTORY_LIST
-
SERVICE_LIST
-
DISTRIBUTION
-
TASK_LIST
-
NODE_LIST
-
CONFIG_LIST
-
SECRET_LIST
-
client
private final javax.ws.rs.client.Client client -
noTimeoutClient
private final javax.ws.rs.client.Client noTimeoutClient -
uri
-
apiVersion
-
registryAuthSupplier
-
headers
-
-
Constructor Details
-
DefaultDockerClient
Create a new client with default configuration.- Parameters:
uri- The docker rest api uri.
-
DefaultDockerClient
Create a new client with default configuration.- Parameters:
uri- The docker rest api uri.
-
DefaultDockerClient
Create a new client with default configuration.- Parameters:
uri- The docker rest api uri.dockerCertificatesStore- The certificates to use for HTTPS.
-
DefaultDockerClient
Create a new client using the configuration of the builder.- Parameters:
builder- DefaultDockerClient builder
-
-
Method Details
-
getClient
javax.ws.rs.client.Client getClient() -
getNoTimeoutClient
javax.ws.rs.client.Client getNoTimeoutClient() -
updateProxy
private org.glassfish.jersey.client.ClientConfig updateProxy(org.glassfish.jersey.client.ClientConfig config, DefaultDockerClient.Builder builder) -
toRegExp
-
getHost
Description copied from interface:DockerClientGet the Docker host address.- Specified by:
getHostin interfaceDockerClient- Returns:
- the docker host name or IP
-
getConnectionManager
private org.apache.http.impl.conn.PoolingHttpClientConnectionManager getConnectionManager(DefaultDockerClient.Builder builder) -
getSchemeRegistry
private org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> getSchemeRegistry(DefaultDockerClient.Builder builder) -
close
public void close()Description copied from interface:DockerClientCloses any and all underlying connections to docker, and release resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceDockerClient
-
ping
Description copied from interface:DockerClientPing the docker daemon. Returns "OK" if all is well, though that it simply returns a 200 status is probably sufficient information.- Specified by:
pingin interfaceDockerClient- Returns:
- String "OK"
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
version
Description copied from interface:DockerClientGet the docker version.- Specified by:
versionin interfaceDockerClient- Returns:
- docker version
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
auth
Description copied from interface:DockerClientCheck auth configuration.- Specified by:
authin interfaceDockerClient- Parameters:
registryAuth- TheRegistryAuthneeded to pull the image.- Returns:
- status code of auth request
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
info
Description copied from interface:DockerClientGet docker instance information.- Specified by:
infoin interfaceDockerClient- Returns:
- docker info
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
listContainers
public List<Container> listContainers(DockerClient.ListContainersParam... params) throws DockerException, InterruptedException Description copied from interface:DockerClientList docker containers.- Specified by:
listContainersin interfaceDockerClient- Parameters:
params- Container listing and filtering options.- Returns:
- A list of containers.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
addParameters
private javax.ws.rs.client.WebTarget addParameters(javax.ws.rs.client.WebTarget resource, DockerClient.Param... params) throws DockerException - Throws:
DockerException
-
getQueryParamMap
-
urlEncode
URL-encodes a string when used as a URL query parameter's value.- Parameters:
unencoded- A string that may contain characters not allowed in URL query parameters.- Returns:
- URL-encoded String
- Throws:
DockerException- if there's an UnsupportedEncodingException
-
urlEncodeFilters
Takes a map of filters and URL-encodes them. If the map is empty or an exception occurs, return null.- Parameters:
filters- A map of filters.- Returns:
- String
- Throws:
DockerException- if there's an IOException
-
listImages
public List<Image> listImages(DockerClient.ListImagesParam... params) throws DockerException, InterruptedException Description copied from interface:DockerClientList docker images.- Specified by:
listImagesin interfaceDockerClient- Parameters:
params- Image listing and filtering options.- Returns:
- A list of images.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
createContainer
public ContainerCreation createContainer(ContainerConfig config) throws DockerException, InterruptedException Description copied from interface:DockerClientCreate a docker container.- Specified by:
createContainerin interfaceDockerClient- Parameters:
config- The container configuration.- Returns:
- Container creation result with container id and eventual warnings from docker.
- Throws:
DockerException- if logs cannot be attached, because container is not running (406), or if a server error occurred (500)InterruptedException- If the thread is interrupted
-
createContainer
public ContainerCreation createContainer(ContainerConfig config, String name) throws DockerException, InterruptedException Description copied from interface:DockerClientCreate a docker container.- Specified by:
createContainerin interfaceDockerClient- Parameters:
config- The container configuration.name- The container name.- Returns:
- Container creation result with container id and eventual warnings from docker.
- Throws:
DockerException- if logs cannot be attached, because container is not running (406), or if a server error occurred (500)InterruptedException- If the thread is interrupted
-
startContainer
Description copied from interface:DockerClientStart a docker container.- Specified by:
startContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to start.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
containerAction
private void containerAction(String containerId, String action) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
containerAction
private void containerAction(String containerId, String action, javax.ws.rs.core.MultivaluedMap<String, String> queryParameters) throws DockerException, InterruptedException- Throws:
DockerExceptionInterruptedException
-
pauseContainer
Description copied from interface:DockerClientPause a docker container.- Specified by:
pauseContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to pause.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
unpauseContainer
Description copied from interface:DockerClientUnpause a docker container.- Specified by:
unpauseContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to pause.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
restartContainer
Description copied from interface:DockerClientRestart a docker container. with a 10 second default wait- Specified by:
restartContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to restart.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
restartContainer
public void restartContainer(String containerId, int secondsToWaitBeforeRestart) throws DockerException, InterruptedException Description copied from interface:DockerClientRestart a docker container.- Specified by:
restartContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to restart.secondsToWaitBeforeRestart- number of seconds to wait before killing the container.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
killContainer
Description copied from interface:DockerClientKill a docker container. Note: by default SIGKILL is sent.- Specified by:
killContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to kill.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
killContainer
public void killContainer(String containerId, DockerClient.Signal signal) throws DockerException, InterruptedException Description copied from interface:DockerClientKill a docker container.- Specified by:
killContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to kill.signal- Signal used to kill the process.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
getDistribution
Description copied from interface:DockerClientGet the distribution of a container.- Specified by:
getDistributionin interfaceDockerClient- Parameters:
imageName- The name of the container.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
stopContainer
public void stopContainer(String containerId, int secondsToWaitBeforeKilling) throws DockerException, InterruptedException Description copied from interface:DockerClientStop 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.- Specified by:
stopContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to stop.secondsToWaitBeforeKilling- Time to wait after SIGTERM before sending SIGKILL.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
waitContainer
Description copied from interface:DockerClientWait for a docker container to exit.- Specified by:
waitContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to wait for.- Returns:
- Exit response with status code.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
removeContainer
Description copied from interface:DockerClientRemove a docker container.- Specified by:
removeContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to remove.- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
removeContainer
@Deprecated public void removeContainer(String containerId, boolean removeVolumes) throws DockerException, InterruptedException Deprecated.Description copied from interface:DockerClientRemove a docker container.- Specified by:
removeContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to remove.removeVolumes- Whether to remove volumes as well.- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
removeContainer
public void removeContainer(String containerId, DockerClient.RemoveContainerParam... params) throws DockerException, InterruptedException Description copied from interface:DockerClientRemove a docker container.- Specified by:
removeContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to remove.params-DockerClient.RemoveContainerParam- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
exportContainer
Description copied from interface:DockerClientExport a docker container as a tar archive.- Specified by:
exportContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to export.- Returns:
- A stream in tar format that contains the contents of the container file system.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
copyContainer
@Deprecated public InputStream copyContainer(String containerId, String path) throws DockerException, InterruptedException Deprecated.Description copied from interface:DockerClientCopies some files out of a container. (removed on API version 1.24)- Specified by:
copyContainerin interfaceDockerClient- Parameters:
containerId- 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.- Returns:
- A stream in tar format that contains the copied files. If a directory was copied, the
directory will be at the root of the tar archive (so
copy(..., "/usr/share")will result in a directory calledsharein 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. - Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
archiveContainer
public InputStream archiveContainer(String containerId, String path) throws DockerException, InterruptedException Description copied from interface:DockerClientCopies an archive out of a container. (API version 1.20+)- Specified by:
archiveContainerin interfaceDockerClient- Parameters:
containerId- 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.- Returns:
- A stream in tar format that contains the copied files. If a directory was copied, the
directory will be at the root of the tar archive (so
copy(..., "/usr/share")will result in a directory calledsharein 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. - Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
topContainer
Description copied from interface:DockerClientList processes running inside the container by usingps.- Specified by:
topContainerin interfaceDockerClient- Parameters:
containerId- the id of the container to examine- Returns:
- the titles and process list for the container
- Throws:
DockerException- if a server error occurred (500).InterruptedException- if the thread is interrupted.
-
topContainer
public TopResults topContainer(String containerId, String psArgs) throws DockerException, InterruptedException Description copied from interface:DockerClientList processes running inside the container usingpsand the given arguments.- Specified by:
topContainerin interfaceDockerClient- Parameters:
containerId- the id of the container to examinepsArgs- the arguments to pass topsinside the container, e.g.,"-ef"- Returns:
- the titles and process list for the container
- Throws:
DockerException- if a server error occurred (500).InterruptedException- if the thread is interrupted.
-
copyToContainer
public void copyToContainer(Path directory, String containerId, String path) throws DockerException, InterruptedException, IOException Description copied from interface:DockerClientCopies some files from host to container. (API version 1.20+)- Specified by:
copyToContainerin interfaceDockerClient- Parameters:
directory- The path to sent to containercontainerId- The id of the container to sent files.path- The path inside of the container to put files.- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interruptedIOException- If IOException
-
copyToContainer
public void copyToContainer(InputStream tarStream, String containerId, String path) throws DockerException, InterruptedException - Specified by:
copyToContainerin interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
inspectContainerChanges
public List<ContainerChange> inspectContainerChanges(String containerId) throws DockerException, InterruptedException Description copied from interface:DockerClientInspect changes on a container's filesystem.- Specified by:
inspectContainerChangesin interfaceDockerClient- Parameters:
containerId- The id of the container.- Returns:
- A list of the changes to the container file system.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
inspectContainer
public ContainerInfo inspectContainer(String containerId) throws DockerException, InterruptedException Description copied from interface:DockerClientInspect a docker container.- Specified by:
inspectContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to inspect.- Returns:
- Info about the container.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
commitContainer
public ContainerCreation commitContainer(String containerId, String repo, String tag, ContainerConfig config, String comment, String author) throws DockerException, InterruptedException Description copied from interface:DockerClientCreate a new image from a container's changes.- Specified by:
commitContainerin interfaceDockerClient- Parameters:
containerId- 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.- Returns:
- ContainerCreation reply.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
renameContainer
public void renameContainer(String containerId, String name) throws DockerException, InterruptedException Description copied from interface:DockerClientRename a docker container.- Specified by:
renameContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to rename.name- The new name the container will have- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
updateContainer
public ContainerUpdate updateContainer(String containerId, HostConfig config) throws DockerException, InterruptedException Description copied from interface:DockerClientUpdate an existing container. Only available in Docker API >= 1.22.- Specified by:
updateContainerin interfaceDockerClient- Parameters:
containerId- the identifier of the containerconfig- the new container host config- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
searchImages
public List<ImageSearchResult> searchImages(String term) throws DockerException, InterruptedException Description copied from interface:DockerClientSearch for images on Docker HubThis method is broken for Docker 1.7.x because of a Docker bug. See https://github.com/docker/docker/pull/14850.
- Specified by:
searchImagesin interfaceDockerClient- Parameters:
term- the search term- Returns:
- a list of matches for the given search term
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
load
@Deprecated public void load(String image, InputStream imagePayload) throws DockerException, InterruptedException Deprecated.Description copied from interface:DockerClientCreates a single image from a tarball. This method also tags the image with the given image name upon loading completion.- Specified by:
loadin interfaceDockerClient- Parameters:
image- the name to assign to the image.imagePayload- the image's payload (i.e.: the stream corresponding to the image's .tar file).- Throws:
DockerException- if a server error occurred (500).InterruptedException- if the thread is interrupted.
-
load
@Deprecated public void load(String image, InputStream imagePayload, ProgressHandler handler) throws DockerException, InterruptedException Deprecated.Description copied from interface:DockerClientCreates a single image from a tarball. This method also tags the image with the given image name upon loading completion.- Specified by:
loadin interfaceDockerClient- Parameters:
image- 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.- Throws:
DockerException- if a server error occurred (500).InterruptedException- if the thread is interrupted.
-
load
Description copied from interface:DockerClientLoad a set of images and tags from a tarball.- Specified by:
loadin interfaceDockerClient- Parameters:
imagePayload- the image's payload (i.e.: the stream corresponding to the image's .tar file).- Returns:
- a set of all loaded images
- Throws:
DockerException- if a server error occurred (500).InterruptedException- if the thread is interrupted.
-
load
public Set<String> load(InputStream imagePayload, ProgressHandler handler) throws DockerException, InterruptedException Description copied from interface:DockerClientLoad a set of images and tags from a tarball, using a custom ProgressMessageHandler.- Specified by:
loadin interfaceDockerClient- Parameters:
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.- Returns:
- a set of all loaded images
- Throws:
DockerException- if a server error occurred (500).InterruptedException- if the thread is interrupted.
-
create
public void create(String image, InputStream imagePayload) throws DockerException, InterruptedException Description copied from interface:DockerClientCreates a single image from a tarball. This method also tags the image with the given image name upon loading completion.- Specified by:
createin interfaceDockerClient- Parameters:
image- the name to assign to the image.imagePayload- the image's payload (i.e.: the stream corresponding to the image's .tar file).- Throws:
DockerException- if a server error occurred (500).InterruptedException- if the thread is interrupted.
-
create
public void create(String image, InputStream imagePayload, ProgressHandler handler) throws DockerException, InterruptedException Description copied from interface:DockerClientCreates a single image from a tarball. This method also tags the image with the given image name upon loading completion.- Specified by:
createin interfaceDockerClient- Parameters:
image- 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.- Throws:
DockerException- if a server error occurred (500).InterruptedException- if the thread is interrupted.
-
save
Description copied from interface:DockerClientGet a tarball containing all images and metadata for the repository specified.- Specified by:
savein interfaceDockerClient- Parameters:
images- the name(s) of one or more images to save. If a specific name and tag (e.g. ubuntu:latest), then only that image (and its parents) are returned. If an image ID, similarly only that image (and its parents) are returned, but with the exclusion of the 'repositories' file in the tarball, as there were no image names referenced.- Returns:
- the images' .tar streams.
- Throws:
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.
-
saveMultiple
public InputStream saveMultiple(String... images) throws DockerException, IOException, InterruptedException Description copied from interface:DockerClientGet a tarball containing all images and metadata for one or more repositories.- Specified by:
saveMultiplein interfaceDockerClient- Parameters:
images- the name or id of the image to save. if it is a specific name and tag (e.g. ubuntu:latest), then only that image (and its parents) are returned; if it is an image ID, similarly only that image (and its parents) are returned and there would be no names referenced in the 'repositories' file for this image ID.- Returns:
- a tar stream containing the image(s)
- Throws:
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.
-
pull
Description copied from interface:DockerClientPull a docker container image.- Specified by:
pullin interfaceDockerClient- Parameters:
image- The image to pull.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
pull
public void pull(String image, ProgressHandler handler) throws DockerException, InterruptedException Description copied from interface:DockerClientPull a docker container image, using a custom ProgressMessageHandler- Specified by:
pullin interfaceDockerClient- Parameters:
image- The image to pull.handler- The handler to use for processing each progress message received from Docker.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
pull
public void pull(String image, RegistryAuth registryAuth) throws DockerException, InterruptedException Description copied from interface:DockerClientPull a private docker container image.- Specified by:
pullin interfaceDockerClient- Parameters:
image- The image to pull.registryAuth- TheRegistryAuthneeded to pull the image.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
pull
public void pull(String image, RegistryAuth registryAuth, ProgressHandler handler) throws DockerException, InterruptedException Description copied from interface:DockerClientPull a private docker container image, using a custom ProgressMessageHandler.- Specified by:
pullin interfaceDockerClient- Parameters:
image- The image to pull.registryAuth- TheRegistryAuthneeded to pull the image.handler- The handler to use for processing each progress message received from Docker.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
push
Description copied from interface:DockerClientPush a docker container image.- Specified by:
pushin interfaceDockerClient- Parameters:
image- The image to push.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
push
public void push(String image, RegistryAuth registryAuth) throws DockerException, InterruptedException - Specified by:
pushin interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
push
public void push(String image, ProgressHandler handler) throws DockerException, InterruptedException Description copied from interface:DockerClientPush a docker container image, using a custom ProgressHandler- Specified by:
pushin interfaceDockerClient- Parameters:
image- The image to push.handler- The handler to use for processing each progress message received from Docker.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
push
public void push(String image, ProgressHandler handler, RegistryAuth registryAuth) throws DockerException, InterruptedException - Specified by:
pushin interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
tag
Description copied from interface:DockerClientTag a docker image.- Specified by:
tagin interfaceDockerClient- Parameters:
image- The image to tag.name- The new name that will be applied to the image.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
tag
public void tag(String image, String name, boolean force) throws DockerException, InterruptedException Description copied from interface:DockerClientTag a docker image.- Specified by:
tagin interfaceDockerClient- Parameters:
image- 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.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
build
public String build(Path directory, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException Description copied from interface:DockerClientBuild a docker image.- Specified by:
buildin interfaceDockerClient- Parameters:
directory- The directory containing the dockerfile.params- Additional flags to use during build.- Returns:
- The id of the built image if successful, otherwise null.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interruptedIOException- If some IO shit happened.
-
build
public String build(Path directory, String name, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException Description copied from interface:DockerClientBuild a docker image.- Specified by:
buildin interfaceDockerClient- Parameters:
directory- 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.- Returns:
- The id of the built image if successful, otherwise null.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interruptedIOException- If some IO shit happened.
-
build
public String build(Path directory, ProgressHandler handler, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException Description copied from interface:DockerClientBuild a docker image.- Specified by:
buildin interfaceDockerClient- Parameters:
directory- 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.- Returns:
- The id of the built image if successful, otherwise null.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interruptedIOException- If some IO shit happened.
-
build
public String build(Path directory, String name, ProgressHandler handler, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException Description copied from interface:DockerClientBuild a docker image.- Specified by:
buildin interfaceDockerClient- Parameters:
directory- 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.- Returns:
- The id of the built image if successful, otherwise null.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interruptedIOException- If some IO shit happened.
-
build
public String build(Path directory, String name, String dockerfile, ProgressHandler handler, DockerClient.BuildParam... params) throws DockerException, InterruptedException, IOException Description copied from interface:DockerClientBuild a docker image.- Specified by:
buildin interfaceDockerClient- Parameters:
directory- 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.- Returns:
- The id of the built image if successful, otherwise null.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interruptedIOException- If some IO shit happened.
-
inspectImage
Description copied from interface:DockerClientInspect a docker container image.- Specified by:
inspectImagein interfaceDockerClient- Parameters:
image- The image to inspect.- Returns:
- Info about the image.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
removeImage
Description copied from interface:DockerClientRemove a docker image.- Specified by:
removeImagein interfaceDockerClient- Parameters:
image- The image to remove.- Returns:
- A list describing each image which was removed.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
removeImage
public List<RemovedImage> removeImage(String image, boolean force, boolean noPrune) throws DockerException, InterruptedException Description copied from interface:DockerClientRemove a docker image.- Specified by:
removeImagein interfaceDockerClient- Parameters:
image- The image to remove.force- Force image removal.noPrune- Do not delete untagged parents.- Returns:
- A list describing each image which was removed.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
history
Description copied from interface:DockerClientReturn the history of the image.- Specified by:
historyin interfaceDockerClient- Parameters:
image- An image name or ID.- Returns:
- A List of
ImageHistory - Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
logs
public LogStream logs(String containerId, DockerClient.LogsParam... params) throws DockerException, InterruptedException Description copied from interface:DockerClientGet docker container logs.- Specified by:
logsin interfaceDockerClient- Parameters:
containerId- The id of the container to get logs for.params- Params for controlling what streams to get and whether to tail or not.- Returns:
- A log message stream.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
events
public EventStream events(DockerClient.EventsParam... params) throws DockerException, InterruptedException Description copied from interface:DockerClientWatches the docker API for events.This method is broken for Docker 1.7.x because of a Docker bug. See https://github.com/docker/docker/issues/14354.
- Specified by:
eventsin interfaceDockerClient- Parameters:
params- The parameters to apply to the events request- Returns:
- An event stream
- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
attachContainer
public LogStream attachContainer(String containerId, DockerClient.AttachParameter... params) throws DockerException, InterruptedException Description copied from interface:DockerClientAttach to the container id.- Specified by:
attachContainerin interfaceDockerClient- Parameters:
containerId- The id of the container to get logs for.params- Params for controlling what streams to get and whether to tail or not.- Returns:
- A log message stream.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
getLogStream
private LogStream getLogStream(String method, javax.ws.rs.client.WebTarget resource, String containerId) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
getServiceLogStream
private LogStream getServiceLogStream(String method, javax.ws.rs.client.WebTarget resource, String serviceId) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
execCreate
public ExecCreation execCreate(String containerId, String[] cmd, DockerClient.ExecCreateParam... params) throws DockerException, InterruptedException Description copied from interface:DockerClientSets up an exec instance in a running container id.- Specified by:
execCreatein interfaceDockerClient- Parameters:
containerId- The id of the containercmd- shell commandparams- Exec params- Returns:
ExecCreation- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
execStart
public LogStream execStart(String execId, DockerClient.ExecStartParameter... params) throws DockerException, InterruptedException Description copied from interface:DockerClientStarts a previously set up exec instance id. If detach is true, this API returns after starting the exec command. Otherwise, this API sets up an interactive session with the exec command.- Specified by:
execStartin interfaceDockerClient- Parameters:
execId- exec idparams- Exec start params- Returns:
- exec output
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
inspectSwarm
Description copied from interface:DockerClientInspect the swarm. Only available in Docker API >= 1.24.- Specified by:
inspectSwarmin interfaceDockerClient- Returns:
- Info about a swarm
- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
initSwarm
Description copied from interface:DockerClientInitialize a new swarm. Only available in Docker API >= 1.24.- Specified by:
initSwarmin interfaceDockerClient- Returns:
- Node ID
- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
joinSwarm
Description copied from interface:DockerClientJoin an existing swarm. Only available in Docker API >= 1.24.- Specified by:
joinSwarmin interfaceDockerClient- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
leaveSwarm
Description copied from interface:DockerClientLeave a swarm. Only available in Docker API >= 1.24.- Specified by:
leaveSwarmin interfaceDockerClient- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
leaveSwarm
Description copied from interface:DockerClientLeave a swarm forcefully. Only available in Docker API >= 1.24. Force leave swarm, even if this is the last manager or if leaving will break the cluster.- Specified by:
leaveSwarmin interfaceDockerClient- Parameters:
force- Whether to leave forcefully- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
updateSwarm
public void updateSwarm(Long version, boolean rotateWorkerToken, boolean rotateManagerToken, boolean rotateManagerUnlockKey, SwarmSpec spec) throws DockerException, InterruptedException Description copied from interface:DockerClientUpdate a swarm. Only available in Docker API >= 1.24.- Specified by:
updateSwarmin interfaceDockerClient- Parameters:
version- The version number of the swarm object being updated. This is required to avoid conflicting writes.rotateWorkerToken- Set to true to rotate the worker join token.rotateManagerToken- Set to true to rotate the worker join token.rotateManagerUnlockKey- Set to true to rotate the manager unlock key.spec-SwarmSpec- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
updateSwarm
public void updateSwarm(Long version, boolean rotateWorkerToken, boolean rotateManagerToken, SwarmSpec spec) throws DockerException, InterruptedException Description copied from interface:DockerClientUpdate a swarm. Only available in Docker API >= 1.24.- Specified by:
updateSwarmin interfaceDockerClient- Parameters:
version- The version number of the swarm object being updated. This is required to avoid conflicting writes.rotateWorkerToken- Set to true to rotate the worker join token.rotateManagerToken- Set to true to rotate the worker join token.spec-SwarmSpec- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
updateSwarm
public void updateSwarm(Long version, boolean rotateWorkerToken, SwarmSpec spec) throws DockerException, InterruptedException Description copied from interface:DockerClientUpdate a swarm. Only available in Docker API >= 1.24.- Specified by:
updateSwarmin interfaceDockerClient- Parameters:
version- The version number of the swarm object being updated. This is required to avoid conflicting writes.rotateWorkerToken- Set to true to rotate the worker join token.spec-SwarmSpec- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
updateSwarm
Description copied from interface:DockerClientUpdate a swarm. Only available in Docker API >= 1.24.- Specified by:
updateSwarmin interfaceDockerClient- Parameters:
version- The version number of the swarm object being updated. This is required to avoid conflicting writes.spec-SwarmSpec- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
unlockKey
Description copied from interface:DockerClientGet an unlock key for unlocking a swarm. Only available in Docker API >= 1.25.- Specified by:
unlockKeyin interfaceDockerClient- Returns:
UnlockKey- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
unlock
Description copied from interface:DockerClientUnlock a swarm. Only available in Docker API >= 1.25.- Specified by:
unlockin interfaceDockerClient- Parameters:
unlockKey-UnlockKey- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
createService
public ServiceCreateResponse createService(ServiceSpec spec) throws DockerException, InterruptedException Description copied from interface:DockerClientCreate a new service. Only available in Docker API >= 1.24.- Specified by:
createServicein interfaceDockerClient- Parameters:
spec- the service spec- Returns:
- Service creation result with service id.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
createService
public ServiceCreateResponse createService(ServiceSpec spec, RegistryAuth config) throws DockerException, InterruptedException Description copied from interface:DockerClientCreate a new service. Only available in Docker API >= 1.24.- Specified by:
createServicein interfaceDockerClient- Parameters:
spec- the service specconfig- the registry authentication configuration- Returns:
- Service creation result with service id.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
inspectService
Description copied from interface:DockerClientInspect an existing service. Only available in Docker API >= 1.24.- Specified by:
inspectServicein interfaceDockerClient- Parameters:
serviceId- the id of the service to inspect- Returns:
- Info about the service
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
updateService
public void updateService(String serviceId, Long version, ServiceSpec spec) throws DockerException, InterruptedException Description copied from interface:DockerClientUpdate an existing service. Only available in Docker API >= 1.24.- Specified by:
updateServicein interfaceDockerClient- Parameters:
serviceId- the identifier of the serviceversion- the version of the servicespec- the new service spec- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
updateService
public void updateService(String serviceId, Long version, ServiceSpec spec, RegistryAuth config) throws DockerException, InterruptedException Description copied from interface:DockerClientUpdate an existing service. Only available in Docker API >= 1.24.- Specified by:
updateServicein interfaceDockerClient- Parameters:
serviceId- the identifier of the serviceversion- the version of the servicespec- the new service specconfig- the registry authentication configuration- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
listServices
Description copied from interface:DockerClientList all services. Only available in Docker API >= 1.24.- Specified by:
listServicesin interfaceDockerClient- Returns:
- A list of services.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
listServices
public List<Service> listServices(Service.Criteria criteria) throws DockerException, InterruptedException Description copied from interface:DockerClientList services that match the given criteria. Only available in Docker API >= 1.24.- Specified by:
listServicesin interfaceDockerClient- Parameters:
criteria- Service listing and filtering options.- Returns:
- A list of
Services - Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
removeService
Description copied from interface:DockerClientRemove an existing service. Only available in Docker API >= 1.24.- Specified by:
removeServicein interfaceDockerClient- Parameters:
serviceId- the id of the service to remove- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
serviceLogs
public LogStream serviceLogs(String serviceId, DockerClient.LogsParam... params) throws DockerException, InterruptedException Description copied from interface:DockerClientGet docker service logs.- Specified by:
serviceLogsin interfaceDockerClient- Parameters:
serviceId- The id of the service to get logs for.params- Params for controlling what streams to get and whether to tail or not.- Returns:
- A log message stream.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
inspectTask
Description copied from interface:DockerClientInspect an existing task. Only available in Docker API >= 1.24.- Specified by:
inspectTaskin interfaceDockerClient- Parameters:
taskId- the id of the task to inspect- Returns:
- Info about the task
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
listTasks
Description copied from interface:DockerClientList all tasks. Only available in Docker API >= 1.24.- Specified by:
listTasksin interfaceDockerClient- Returns:
- A list of tasks.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
listTasks
Description copied from interface:DockerClientList tasks that match the given criteria. Only available in Docker API >= 1.24.- Specified by:
listTasksin interfaceDockerClient- Parameters:
criteria-Task.Criteria- Returns:
- A list of tasks.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
listConfigs
Description copied from interface:DockerClientList swarm configs. Only available in Docker API >= 1.30.- Specified by:
listConfigsin interfaceDockerClient- Returns:
- a list of configs
- Throws:
DockerException- if a server error occurred (500)InterruptedException- if the thread is interrupted
-
listConfigs
public List<Config> listConfigs(Config.Criteria criteria) throws DockerException, InterruptedException Description copied from interface:DockerClientList swarm configs. Only available in Docker API >= 1.30.- Specified by:
listConfigsin interfaceDockerClient- Parameters:
criteria- Config listing and filtering options- Returns:
- a list of configs.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- if the thread is interrupted
-
createConfig
public ConfigCreateResponse createConfig(ConfigSpec config) throws DockerException, InterruptedException Description copied from interface:DockerClientCreate a config. Only available in Docker API >= 1.30.- Specified by:
createConfigin interfaceDockerClient- Parameters:
config- The spec for the config.- Returns:
ConfigCreateResponse- Throws:
DockerException- if node is not part of a swarm (503) or a server error occurred (500)InterruptedException
-
inspectConfig
Description copied from interface:DockerClientInspect a config. Only available in Docker API >= 1.30.- Specified by:
inspectConfigin interfaceDockerClient- Parameters:
configId- The id of the config.- Returns:
Config- Throws:
DockerException- if node is not part of a swarm (503) or a server error occurred (500)InterruptedException
-
deleteConfig
Description copied from interface:DockerClientDelete a config. Only available in Docker API >= 1.30.- Specified by:
deleteConfigin interfaceDockerClient- Parameters:
configId- The id of the config.- Throws:
DockerException- if node is not part of a swarm (503) or a server error occurred (500)InterruptedException
-
updateConfig
public void updateConfig(String configId, Long version, ConfigSpec nodeSpec) throws DockerException, InterruptedException Description copied from interface:DockerClientUpdate a swarm config. Only available in Docker API >= 1.30.- Specified by:
updateConfigin interfaceDockerClient- Parameters:
configId- The id of the config to updateversion- The version number of the config object being updated. This is required to avoid conflicting writes- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
listNodes
Description copied from interface:DockerClientList swarm nodes. Only available in Docker API >= 1.24.- Specified by:
listNodesin interfaceDockerClient- Returns:
- A list of nodes.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
listNodes
Description copied from interface:DockerClientList swarm nodes that match the given criteria. Only available in Docker API >= 1.24.- Specified by:
listNodesin interfaceDockerClient- Parameters:
criteria- Node listing and filtering options.- Returns:
- A list of nodes.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
inspectNode
Description copied from interface:DockerClientInspects a swarm node. Only available in Docker API >= 1.24.- Specified by:
inspectNodein interfaceDockerClient- Parameters:
nodeId- The id of the swarm node to inspect- Returns:
- info about the node
- Throws:
DockerException- if a server error occurred (500)InterruptedException- if the thread is interrupted
-
updateNode
public void updateNode(String nodeId, Long version, NodeSpec nodeSpec) throws DockerException, InterruptedException Description copied from interface:DockerClientUpdate a swarm node. Only available in Docker API >= 1.24.- Specified by:
updateNodein interfaceDockerClient- Parameters:
nodeId- The id of the node to updateversion- The version number of the node object being updated. This is required to avoid conflicting writes- Throws:
DockerException- If a server error occurred (500)InterruptedException- If the thread is interrupted
-
deleteNode
Description copied from interface:DockerClientRemove a node from the swarm.- Specified by:
deleteNodein interfaceDockerClient- Parameters:
nodeId- The id of the node to remove.- Throws:
DockerExceptionInterruptedException
-
deleteNode
Description copied from interface:DockerClientRemove a node from the swarm.- Specified by:
deleteNodein interfaceDockerClient- Parameters:
nodeId- The id of the node to remove.force- Forcefully remove the node.- Throws:
DockerExceptionInterruptedException
-
execResizeTty
public void execResizeTty(String execId, Integer height, Integer width) throws DockerException, InterruptedException Description copied from interface:DockerClientResizes the tty session used by an exec command. This API is valid only ifttywas specified as part ofcreatingandstartingthe exec command.- Specified by:
execResizeTtyin interfaceDockerClient- Parameters:
execId- exec idheight- height of tty sessionwidth- width of tty session- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
execInspect
Description copied from interface:DockerClientInspects a running or previously run exec instance id.- Specified by:
execInspectin interfaceDockerClient- Parameters:
execId- exec id- Returns:
- state of this exec instance.
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
stats
Description copied from interface:DockerClientRetrieves one-time stats (stream=0) for the container with the specified id.- Specified by:
statsin interfaceDockerClient- Parameters:
containerId- The id of the container to retrieve stats for.- Returns:
- The container stats
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
resizeTty
public void resizeTty(String containerId, Integer height, Integer width) throws DockerException, InterruptedException Description copied from interface:DockerClientResize container TTY This API is valid only ifttywas specified as part ofcreatingthe container.- Specified by:
resizeTtyin interfaceDockerClient- Parameters:
containerId- The id of the container whose TTY will be resized.height- New height of TTYwidth- New width of TTY- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
checkTtyParams
- Throws:
BadParamException
-
listNetworks
public List<Network> listNetworks(DockerClient.ListNetworksParam... params) throws DockerException, InterruptedException Description copied from interface:DockerClientList all or a subset of the networks. Filters were added in Docker 1.10, API version 1.22.- Specified by:
listNetworksin interfaceDockerClient- Returns:
- networks
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
inspectNetwork
Description copied from interface:DockerClientInspect a specific network.- Specified by:
inspectNetworkin interfaceDockerClient- Parameters:
networkId- The id of the network- Returns:
- network information
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
createNetwork
public NetworkCreation createNetwork(NetworkConfig networkConfig) throws DockerException, InterruptedException Description copied from interface:DockerClientCreate a new network.- Specified by:
createNetworkin interfaceDockerClient- Parameters:
networkConfig- The network creation parameters- Returns:
- NetworkCreation
- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
removeNetwork
Description copied from interface:DockerClientRemove a docker network.- Specified by:
removeNetworkin interfaceDockerClient- Parameters:
networkId- The id of the network to remove.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
connectToNetwork
public void connectToNetwork(String containerId, String networkId) throws DockerException, InterruptedException Description copied from interface:DockerClientConnects a docker container to a network.- Specified by:
connectToNetworkin interfaceDockerClient- Parameters:
containerId- The id of the container to connect.networkId- The id of the network to connect.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
connectToNetwork
public void connectToNetwork(String networkId, NetworkConnection networkConnection) throws DockerException, InterruptedException Description copied from interface:DockerClientConnects a docker container to a network, with extended configuration. This is useful when you want to set specific details (aliases, gateway, etc...) for your container inside the network.- Specified by:
connectToNetworkin interfaceDockerClient- Parameters:
networkId- The id of the network to connect.networkConnection- The target connection parameters.- Throws:
DockerException- if a server error occurred (500)InterruptedException- if the thread is interrupted
-
disconnectFromNetwork
public void disconnectFromNetwork(String containerId, String networkId) throws DockerException, InterruptedException Description copied from interface:DockerClientDisconnects a docker container to a network.- Specified by:
disconnectFromNetworkin interfaceDockerClient- Parameters:
containerId- The id of the container to disconnect.networkId- The id of the network to disconnect.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
disconnectFromNetwork
public void disconnectFromNetwork(String containerId, String networkId, boolean force) throws DockerException, InterruptedException Description copied from interface:DockerClientDisconnects a docker container to a network.- Specified by:
disconnectFromNetworkin interfaceDockerClient- Parameters:
containerId- The id of the container to disconnect.networkId- The id of the network to disconnect.force- Force the container to disconnect from the network.- Throws:
DockerException- if a server error occurred (500)InterruptedException- If the thread is interrupted
-
createVolume
- Specified by:
createVolumein interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
createVolume
- Specified by:
createVolumein interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
inspectVolume
- Specified by:
inspectVolumein interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
removeVolume
- Specified by:
removeVolumein interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
removeVolume
- Specified by:
removeVolumein interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
listVolumes
public VolumeList listVolumes(DockerClient.ListVolumesParam... params) throws DockerException, InterruptedException - Specified by:
listVolumesin interfaceDockerClient- Throws:
DockerExceptionInterruptedException
-
listSecrets
Description copied from interface:DockerClientList secrets.- Specified by:
listSecretsin interfaceDockerClient- Returns:
- A list of
Secrets - Throws:
DockerException- if a server error occurred (500)InterruptedException
-
createSecret
public SecretCreateResponse createSecret(SecretSpec secret) throws DockerException, InterruptedException Description copied from interface:DockerClientCreate a secret.- Specified by:
createSecretin interfaceDockerClient- Parameters:
secret- The spec for the secret.- Returns:
SecretCreateResponse- Throws:
DockerException- if node is not part of a swarm (406) or a server error occurred (500)InterruptedException
-
inspectSecret
Description copied from interface:DockerClientInspect a secret.- Specified by:
inspectSecretin interfaceDockerClient- Parameters:
secretId- The id of the secret.- Returns:
Secret- Throws:
DockerException- if node is not part of a swarm (406) or a server error occurred (500)InterruptedException
-
deleteSecret
Description copied from interface:DockerClientDelete a secret.- Specified by:
deleteSecretin interfaceDockerClient- Parameters:
secretId- The id of the secret.- Throws:
DockerException- if a server error occurred (500)InterruptedException
-
resource
private javax.ws.rs.client.WebTarget resource() -
noTimeoutResource
private javax.ws.rs.client.WebTarget noTimeoutResource() -
request
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 - Throws:
DockerExceptionInterruptedException
-
request
private <T> T request(String method, Class<T> clazz, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
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) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
request
private void request(String method, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
tailResponse
private void tailResponse(String method, javax.ws.rs.core.Response response, ProgressHandler handler, javax.ws.rs.client.WebTarget resource) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
requestAndTail
private void requestAndTail(String method, ProgressHandler handler, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request, javax.ws.rs.client.Entity<?> entity) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
requestAndTail
private void requestAndTail(String method, ProgressHandler handler, javax.ws.rs.client.WebTarget resource, javax.ws.rs.client.Invocation.Builder request) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
headers
private javax.ws.rs.client.Invocation.Builder headers(javax.ws.rs.client.Invocation.Builder request) -
propagate
private RuntimeException propagate(String method, javax.ws.rs.client.WebTarget resource, Exception ex) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
message
-
authHeader
- Throws:
DockerException
-
authRegistryHeader
- Throws:
DockerException
-
assertApiVersionIsAbove
private void assertApiVersionIsAbove(String minimumVersion) throws DockerException, InterruptedException - Throws:
DockerExceptionInterruptedException
-
builder
Create a newDefaultDockerClientbuilder.- Returns:
- Returns a builder that can be used to further customize and then build the client.
-
fromEnv
Create a newDefaultDockerClientbuilder prepopulated with values loaded from the DOCKER_HOST and DOCKER_CERT_PATH environment variables.- Returns:
- Returns a builder that can be used to further customize and then build the client.
- Throws:
DockerCertificateException- if we could not build a DockerCertificates object
-