|
1 | 1 | package org.testcontainers.utility;
|
2 | 2 |
|
3 | 3 | import com.github.dockerjava.api.DockerClient;
|
| 4 | +import com.github.dockerjava.api.async.ResultCallback; |
4 | 5 | import com.github.dockerjava.api.command.InspectContainerResponse;
|
5 | 6 | import com.github.dockerjava.api.exception.NotFoundException;
|
6 | 7 | import com.github.dockerjava.api.model.Bind;
|
7 | 8 | import com.github.dockerjava.api.model.ExposedPort;
|
| 9 | +import com.github.dockerjava.api.model.Frame; |
8 | 10 | import com.github.dockerjava.api.model.HostConfig;
|
9 | 11 | import com.github.dockerjava.api.model.Network;
|
10 | 12 | import com.github.dockerjava.api.model.Ports;
|
|
28 | 30 | import java.io.UnsupportedEncodingException;
|
29 | 31 | import java.net.Socket;
|
30 | 32 | import java.net.URLEncoder;
|
| 33 | +import java.nio.charset.StandardCharsets; |
31 | 34 | import java.util.AbstractMap.SimpleEntry;
|
32 | 35 | import java.util.ArrayList;
|
33 | 36 | import java.util.Collections;
|
@@ -93,6 +96,20 @@ public static String start(String hostIpAddress, DockerClient client) {
|
93 | 96 |
|
94 | 97 | client.startContainerCmd(ryukContainerId).exec();
|
95 | 98 |
|
| 99 | + StringBuilder ryukLog = new StringBuilder(); |
| 100 | + |
| 101 | + client.logContainerCmd(ryukContainerId) |
| 102 | + .withSince(0) |
| 103 | + .withFollowStream(true) |
| 104 | + .withStdOut(true) |
| 105 | + .withStdErr(true) |
| 106 | + .exec(new ResultCallback.Adapter<Frame>() { |
| 107 | + @Override |
| 108 | + public void onNext(Frame frame) { |
| 109 | + ryukLog.append(new String(frame.getPayload(), StandardCharsets.UTF_8)); |
| 110 | + } |
| 111 | + }); |
| 112 | + |
96 | 113 | InspectContainerResponse inspectedContainer = client.inspectContainerCmd(ryukContainerId).exec();
|
97 | 114 |
|
98 | 115 | Integer ryukPort = inspectedContainer.getNetworkSettings().getPorts().getBindings().values().stream()
|
@@ -155,7 +172,8 @@ public static String start(String hostIpAddress, DockerClient client) {
|
155 | 172 |
|
156 | 173 | // We need to wait before we can start any containers to make sure that we delete them
|
157 | 174 | if (!ryukScheduledLatch.await(TestcontainersConfiguration.getInstance().getRyukTimeout(), TimeUnit.SECONDS)) {
|
158 |
| - throw new IllegalStateException("Can not connect to Ryuk"); |
| 175 | + log.error("Timeout out waiting for Ryuk. Ryuk's log:\n{}", ryukLog); |
| 176 | + throw new IllegalStateException(String.format("Can not connect to Ryuk at %s:%s", hostIpAddress, ryukPort)); |
159 | 177 | }
|
160 | 178 |
|
161 | 179 | return ryukContainerId;
|
|
0 commit comments