public class DockerClient
extends java.lang.Object
docker
CLI.Modifier and Type | Class and Description |
---|---|
static class |
DockerClient.DockerImageDetails
Contains the size, image ID, and diff IDs of an image inspected with
docker inspect . |
Modifier and Type | Field and Description |
---|---|
static java.nio.file.Path |
DEFAULT_DOCKER_CLIENT
Default path to the docker executable.
|
Constructor and Description |
---|
DockerClient(java.nio.file.Path dockerExecutable,
java.util.Map<java.lang.String,java.lang.String> dockerEnvironment)
Instantiates with a
docker executable and environment variables. |
Modifier and Type | Method and Description |
---|---|
DockerClient.DockerImageDetails |
inspect(ImageReference imageReference)
Gets the size, image ID, and diff IDs of an image in the Docker daemon.
|
static boolean |
isDefaultDockerInstalled()
Checks if Docker is installed on the user's system and accessible by running the default
docker command. |
static boolean |
isDockerInstalled(java.nio.file.Path dockerExecutable)
Checks if Docker is installed on the user's system and accessible by running the given
docker executable. |
java.lang.String |
load(ImageTarball imageTarball,
java.util.function.Consumer<java.lang.Long> writtenByteCountListener)
Loads an image tarball into the Docker daemon.
|
void |
save(ImageReference imageReference,
java.nio.file.Path outputPath,
java.util.function.Consumer<java.lang.Long> writtenByteCountListener)
Saves an image tarball from the Docker daemon.
|
public static final java.nio.file.Path DEFAULT_DOCKER_CLIENT
public DockerClient(java.nio.file.Path dockerExecutable, java.util.Map<java.lang.String,java.lang.String> dockerEnvironment)
docker
executable and environment variables.dockerExecutable
- path to docker
dockerEnvironment
- environment variables for docker
public static boolean isDefaultDockerInstalled()
docker
command.true
if Docker is installed on the user's system and accessiblepublic static boolean isDockerInstalled(java.nio.file.Path dockerExecutable)
docker
executable.dockerExecutable
- path to the executable to test runningtrue
if Docker is installed on the user's system and accessiblepublic java.lang.String load(ImageTarball imageTarball, java.util.function.Consumer<java.lang.Long> writtenByteCountListener) throws java.lang.InterruptedException, java.io.IOException
imageTarball
- the built container tarballwrittenByteCountListener
- callback to call when bytes are loadeddocker
java.lang.InterruptedException
- if the 'docker load' process is interruptedjava.io.IOException
- if streaming the blob to 'docker load' failspublic void save(ImageReference imageReference, java.nio.file.Path outputPath, java.util.function.Consumer<java.lang.Long> writtenByteCountListener) throws java.lang.InterruptedException, java.io.IOException
imageReference
- the image to saveoutputPath
- the destination path to save the output tarballwrittenByteCountListener
- callback to call when bytes are savedjava.lang.InterruptedException
- if the 'docker save' process is interruptedjava.io.IOException
- if creating the tarball failspublic DockerClient.DockerImageDetails inspect(ImageReference imageReference) throws java.io.IOException, java.lang.InterruptedException
imageReference
- the image to inspectjava.io.IOException
- if an I/O exception occurs or docker inspect
failedjava.lang.InterruptedException
- if the docker inspect
process was interrupted