Skip to content

Commit f602d82

Browse files
Yury Bubnovrnorth
authored andcommitted
fix for #536
1 parent d7551de commit f602d82

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import org.zeroturnaround.exec.stream.slf4j.Slf4jStream;
2424

2525
import java.io.File;
26+
import java.nio.file.Files;
27+
import java.nio.file.Path;
28+
import java.nio.file.Paths;
2629
import java.util.*;
2730
import java.util.AbstractMap.SimpleEntry;
2831
import java.util.concurrent.ConcurrentHashMap;
@@ -359,6 +362,7 @@ default void validateFileList(List<File> composeFiles) {
359362
class ContainerisedDockerCompose extends GenericContainer<ContainerisedDockerCompose> implements DockerCompose {
360363

361364
private static final String DOCKER_SOCKET_PATH = "/var/run/docker.sock";
365+
private static final String DOCKER_CONFIG_PATH = "/root/.docker";
362366
public static final char UNIX_PATH_SEPERATOR = ':';
363367

364368
public ContainerisedDockerCompose(List<File> composeFiles, String identifier) {
@@ -391,6 +395,11 @@ public ContainerisedDockerCompose(List<File> composeFiles, String identifier) {
391395
addEnv("DOCKER_HOST", "unix:///docker.sock");
392396
setStartupCheckStrategy(new IndefiniteWaitOneShotStartupCheckStrategy());
393397
setWorkingDirectory(containerPwd);
398+
Path dockerConfig = Paths.get(System.getProperty("user.home"), ".docker");
399+
if (Files.exists(dockerConfig)){
400+
addFileSystemBind(dockerConfig.toString(), DOCKER_CONFIG_PATH, READ_ONLY);
401+
}
402+
394403
}
395404

396405
private String getDockerSocketHostPath() {

0 commit comments

Comments
 (0)