Skip to content

Commit 07f25b5

Browse files
Try explicitly mounting the Docker socket into the Reaper
1 parent 973a9a0 commit 07f25b5

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/reaper.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,17 @@ export class Reaper {
2828
const sessionId = dockerClient.getSessionId();
2929

3030
log.debug(`Creating new Reaper for session: ${sessionId}`);
31-
const container = new GenericContainer(this.IMAGE_NAME, "0.3.0")
31+
const container = await new GenericContainer(this.IMAGE_NAME, "0.3.0")
3232
.withName(`ryuk-${sessionId}`)
3333
.withExposedPorts(8080)
3434
.withWaitStrategy(Wait.forLogMessage("Started!"))
35+
.withBindMount(dockerClient.getSocketPath() || "/var/run/docker.sock", "/var/run/docker.sock")
3536
.withDaemonMode()
36-
.withPrivilegedMode();
37-
38-
if (process.env.DOCKER_HOST) {
39-
container.withEnv("DOCKER_HOST", process.env.DOCKER_HOST);
40-
} else {
41-
container.withBindMount(dockerClient.getSocketPath(), "/var/run/docker.sock");
42-
}
43-
44-
const startedContainer = await container.start();
37+
.withPrivilegedMode()
38+
.start();
4539

4640
const host = dockerClient.getHost();
47-
const port = startedContainer.getMappedPort(8080);
41+
const port = container.getMappedPort(8080);
4842

4943
log.debug(`Connecting to Reaper on ${host}:${port}`);
5044
const socket = new Socket();
@@ -59,7 +53,7 @@ export class Reaper {
5953
socket.connect(port, host, () => {
6054
log.debug(`Connected to Reaper`);
6155
socket.write(`label=org.testcontainers.session-id=${sessionId}\r\n`);
62-
const reaper = new Reaper(sessionId, startedContainer, socket);
56+
const reaper = new Reaper(sessionId, container, socket);
6357
resolve(reaper);
6458
});
6559
});

0 commit comments

Comments
 (0)