Skip to content

Commit a2a59bc

Browse files
authored
Implement DockerClientFactory.isDockerAvailable() (#2605)
1 parent f84bcd6 commit a2a59bc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/src/main/java/org/testcontainers/DockerClientFactory.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ public synchronized static DockerClientFactory instance() {
101101
return instance;
102102
}
103103

104+
/**
105+
* Checks whether Docker is accessible and {@link #client()} is able to produce a client.
106+
* @return true if Docker is available, false if not.
107+
*/
108+
public synchronized boolean isDockerAvailable() {
109+
try {
110+
client();
111+
return true;
112+
} catch (IllegalStateException ex) {
113+
return false;
114+
}
115+
}
116+
104117
@Synchronized
105118
private DockerClientProviderStrategy getOrInitializeStrategy() {
106119
if (strategy != null) {

0 commit comments

Comments
 (0)