public class CliDockerClient extends java.lang.Object implements DockerClient
docker
CLI.Modifier and Type | Class and Description |
---|---|
static class |
CliDockerClient.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 |
---|
CliDockerClient(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 |
---|---|
CliDockerClient.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 by running the `docker` command.
|
static boolean |
isDockerInstalled(java.nio.file.Path dockerExecutable)
Checks if Docker is installed on the user's system and by verifying if the executable path
provided has the appropriate permissions.
|
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.
|
boolean |
supported(java.util.Map<java.lang.String,java.lang.String> parameters)
Validate if the DockerClient is supported.
|
public static final java.nio.file.Path DEFAULT_DOCKER_CLIENT
public CliDockerClient(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()
true
if Docker is installed on the user's system and accessiblepublic static boolean isDockerInstalled(java.nio.file.Path dockerExecutable)
dockerExecutable
- path to the executable to test runningtrue
if Docker is installed on the user's system and accessiblepublic boolean supported(java.util.Map<java.lang.String,java.lang.String> parameters)
DockerClient
supported
in interface DockerClient
parameters
- to be used by the docker clientpublic java.lang.String load(ImageTarball imageTarball, java.util.function.Consumer<java.lang.Long> writtenByteCountListener) throws java.lang.InterruptedException, java.io.IOException
DockerClient
load
in interface DockerClient
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
DockerClient
save
in interface DockerClient
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 CliDockerClient.DockerImageDetails inspect(ImageReference imageReference) throws java.io.IOException, java.lang.InterruptedException
DockerClient
inspect
in interface DockerClient
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