Skip to content

Commit

Permalink
Implement DockerClientFactory.isDockerAvailable() (testcontainers#2605)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny authored and quincy committed May 28, 2020
1 parent 5469243 commit 4929a6c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/main/java/org/testcontainers/DockerClientFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ public synchronized static DockerClientFactory instance() {
return instance;
}

/**
* Checks whether Docker is accessible and {@link #client()} is able to produce a client.
* @return true if Docker is available, false if not.
*/
public synchronized boolean isDockerAvailable() {
try {
client();
return true;
} catch (IllegalStateException ex) {
return false;
}
}

@Synchronized
private DockerClientProviderStrategy getOrInitializeStrategy() {
if (strategy != null) {
Expand Down

0 comments on commit 4929a6c

Please sign in to comment.