Skip to content

Commit d1498fc

Browse files
committed
moved path detection to separate method
1 parent 24f2d1f commit d1498fc

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file.
33

44
### Fixed
55
- Fixed retrieval of Docker host IP when running inside Docker. ([\#479](https://github.com/testcontainers/testcontainers-java/issues/479))
6-
- Compose can now pull images from private repositories.
6+
- Compose is now able to pull images from private repositories. ([\#536](https://github.com/testcontainers/testcontainers-java/issues/536))
77
- Fixed overriding MySQL image command. ([\#534](https://github.com/testcontainers/testcontainers-java/issues/534))
88

99
### Changed

core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)