Package io.github.pgatzka.docker.service
Class DockerService
java.lang.Object
io.github.pgatzka.docker.service.DockerService
- All Implemented Interfaces:
AutoCloseable,org.gradle.api.services.BuildService<org.gradle.api.services.BuildServiceParameters.None>
public abstract class DockerService
extends Object
implements org.gradle.api.services.BuildService<org.gradle.api.services.BuildServiceParameters.None>, AutoCloseable
Gradle
BuildService that owns a single DockerClient for the whole build. The
first call to getClient() constructs the client lazily and pings the daemon (the
precheck runs at most once per service instance). Implements AutoCloseable so Gradle
closes the underlying HTTP client at build end.-
Constructor Summary
ConstructorsConstructorDescriptionInvoked by Gradle's bytecode-decorated subclass; not for direct use. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the underlyingDockerClient, if any, and reset internal state so the service can be reused.com.github.dockerjava.api.DockerClientLazily construct the sharedDockerClienton first call and verify the daemon is reachable; subsequent calls return the cached client without re-pinging.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.services.BuildService
getParameters
-
Constructor Details
-
DockerService
public DockerService()Invoked by Gradle's bytecode-decorated subclass; not for direct use.
-
-
Method Details
-
getClient
public com.github.dockerjava.api.DockerClient getClient()Lazily construct the sharedDockerClienton first call and verify the daemon is reachable; subsequent calls return the cached client without re-pinging.- Returns:
- the shared
DockerClientafter a successful daemon precheck - Throws:
org.gradle.api.GradleException- if the daemon is unreachable on the first call
-
close
Close the underlyingDockerClient, if any, and reset internal state so the service can be reused. Called by Gradle at the end of the build.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException- if the underlying client's close fails
-