Class Readiness
java.lang.Object
io.github.pgatzka.docker.internal.Readiness
Container readiness probes used by start tasks. Each probe blocks the calling thread until the
desired condition is met or
timeout elapses, in which case a NotReadyException
is thrown. Stateless utility — instances are not constructible.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidhealthcheck(com.github.dockerjava.api.DockerClient client, String containerId, Duration timeout, Duration pollInterval) Poll the daemon's healthcheck status forcontainerIduntil it reportshealthyortimeoutelapses.static voidlogLine(com.github.dockerjava.api.DockerClient client, String containerId, String regex, Duration timeout) Stream the container's combined stdout/stderr logs until a line matchesregexortimeoutelapses.static booleanlogLineMatch(String text, String regex) Pure-logic helper used by unit tests: returns whether any line intextmatchesregex.static voidRepeatedly attempt a TCP connection tohost:portuntil one succeeds ortimeoutelapses.
-
Method Details
-
healthcheck
public static void healthcheck(com.github.dockerjava.api.DockerClient client, String containerId, Duration timeout, Duration pollInterval) Poll the daemon's healthcheck status forcontainerIduntil it reportshealthyortimeoutelapses.- Parameters:
client- the docker-java client used to inspect the containercontainerId- the daemon-side container id (or name)timeout- maximum time to wait for thehealthystatuspollInterval- delay between successive inspect calls- Throws:
NotReadyException- if the container disappears, is interrupted, or never becomes healthy withintimeout
-
tcpPort
Repeatedly attempt a TCP connection tohost:portuntil one succeeds ortimeoutelapses. Each connection attempt usespollIntervalas its socket connect timeout, and the loop also sleepspollIntervalbetween attempts.- Parameters:
host- the host to connect to (typicallylocalhostfor published ports)port- the TCP port to probetimeout- maximum total time to wait for a successful connectionpollInterval- per-attempt connect timeout and delay between attempts- Throws:
NotReadyException- if no connection succeeds withintimeoutor the thread is interrupted while waiting
-
logLine
public static void logLine(com.github.dockerjava.api.DockerClient client, String containerId, String regex, Duration timeout) Stream the container's combined stdout/stderr logs until a line matchesregexortimeoutelapses. Partial frames are buffered so a match split across docker log frames is still detected.- Parameters:
client- the docker-java client used to follow the log streamcontainerId- the daemon-side container id (or name)regex- Java regular expression matched against each complete log linetimeout- maximum time to wait for a matching line- Throws:
NotReadyException- if no matching line is observed withintimeout, the stream is interrupted, or it closes before a match is seen
-
logLineMatch
Pure-logic helper used by unit tests: returns whether any line intextmatchesregex. Does not read from a docker daemon.- Parameters:
text- multi-line text, lines separated by\nor\r\nregex- Java regular expression matched against each line- Returns:
trueif at least one line contains a match forregex
-