@@ -66,7 +66,7 @@ public class DockerClientFactory {
6666 DockerClient dockerClient ;
6767
6868 @ VisibleForTesting
69- RuntimeException cachedChecksFailure ;
69+ RuntimeException cachedClientFailure ;
7070
7171 private String activeApiVersion ;
7272 private String activeExecutionDriver ;
@@ -139,9 +139,9 @@ public DockerClient client() {
139139 }
140140
141141 // fail-fast if checks have failed previously
142- if (cachedChecksFailure != null ) {
143- log .debug ("There is a cached checks failure - throwing" , cachedChecksFailure );
144- throw cachedChecksFailure ;
142+ if (cachedClientFailure != null ) {
143+ log .debug ("There is a cached checks failure - throwing" , cachedClientFailure );
144+ throw cachedClientFailure ;
145145 }
146146
147147 final DockerClientProviderStrategy strategy = getOrInitializeStrategy ();
@@ -170,7 +170,12 @@ public void close() {
170170 boolean useRyuk = !Boolean .parseBoolean (System .getenv ("TESTCONTAINERS_RYUK_DISABLED" ));
171171 if (useRyuk ) {
172172 log .debug ("Ryuk is enabled" );
173- ryukContainerId = ResourceReaper .start (hostIpAddress , client );
173+ try {
174+ ryukContainerId = ResourceReaper .start (hostIpAddress , client );
175+ } catch (RuntimeException e ) {
176+ cachedClientFailure = e ;
177+ throw e ;
178+ }
174179 log .info ("Ryuk started - will monitor and terminate Testcontainers containers on JVM exit" );
175180 } else {
176181 log .debug ("Ryuk is disabled" );
@@ -201,7 +206,7 @@ public void close() {
201206 );
202207 }
203208 } catch (RuntimeException e ) {
204- cachedChecksFailure = e ;
209+ cachedClientFailure = e ;
205210 throw e ;
206211 }
207212 } else {
0 commit comments