@@ -399,18 +399,26 @@ public ContainerisedDockerCompose(List<File> composeFiles, String identifier) {
399399 setStartupCheckStrategy (new IndefiniteWaitOneShotStartupCheckStrategy ());
400400 setWorkingDirectory (containerPwd );
401401
402+ String dockerConfigPath = determineDockerConfigPath ();
403+ if (dockerConfigPath != null && dockerConfigPath .isEmpty ()) {
404+ addFileSystemBind (dockerConfigPath , DOCKER_CONFIG_FILE , READ_ONLY );
405+ }
406+ }
407+
408+ private String determineDockerConfigPath () {
402409 String dockerConfigEnv = System .getenv (DOCKER_CONFIG_ENV );
403410 String dockerConfigProperty = System .getProperty (DOCKER_CONFIG_PROPERTY );
404411 Path dockerConfig = Paths .get (System .getProperty ("user.home" ), ".docker" , "config.json" );
405412
406413 if (dockerConfigEnv != null && !dockerConfigEnv .trim ().isEmpty () && Files .exists (Paths .get (dockerConfigEnv ))) {
407- addFileSystemBind ( dockerConfigEnv , DOCKER_CONFIG_FILE , READ_ONLY ) ;
414+ return dockerConfigEnv ;
408415 } else if (dockerConfigProperty != null && !dockerConfigProperty .trim ().isEmpty () && Files .exists (Paths .get (dockerConfigProperty ))) {
409- addFileSystemBind ( dockerConfigProperty , DOCKER_CONFIG_FILE , READ_ONLY ) ;
416+ return dockerConfigProperty ;
410417 } else if (Files .exists (dockerConfig )) {
411- addFileSystemBind (dockerConfig .toString (), DOCKER_CONFIG_FILE , READ_ONLY );
418+ return dockerConfig .toString ();
419+ } else {
420+ return null ;
412421 }
413-
414422 }
415423
416424 private String getDockerSocketHostPath () {
0 commit comments