Repository navigation
Description
As described in the proof of concept project
https://github.com/mariusneo/dockerized-maven-build
while trying to execute tests that rely on testcontainers library while building a docker image with the docker RUN command
RUN mvn clean test
the following error occurs:
2019-02-25 16:06:46 WARN ResourceReaper:137 - Can not connect to Ryuk at my.docker.host:32866
java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
at java.base/java.net.Socket.connect(Socket.java:591)
at java.base/java.net.Socket.connect(Socket.java:540)
at java.base/java.net.Socket.<init>(Socket.java:436)
at java.base/java.net.Socket.<init>(Socket.java:213)
at org.testcontainers.utility.ResourceReaper.lambda$start$1(ResourceReaper.java:112)
at java.base/java.lang.Thread.run(Thread.java:834)
NOTE that in the provided example the DOCKER_HOST environment variable is set to a machine different than the one where the docker image is being built.
ARG dockerHost
ENV DOCKER_HOST=${dockerHost}
On the other hand, if in the Dockerfile the environment variable TESTCONTAINERS_RYUK_DISABLED is set to true
ENV TESTCONTAINERS_RYUK_DISABLED="true"
the tests that spawn the docker containers during the tests will run just fine.
My assumption is that the place to perform the change would be in the ResourceReaper class
public static String start(String hostIpAddress, DockerClient client) {
String ryukImage = TestcontainersConfiguration.getInstance().getRyukImage();
DockerClientFactory.instance().checkAndPullImage(client, ryukImage);
List<Bind> binds = new ArrayList<>();
binds.add(new Bind("//var/run/docker.sock", new Volume("/var/run/docker.sock")));
where the /var/run/docker.sock volume binding is done explicitly to /var/run/docker.sock.
I assume that here would be more appropriate to use the dockerHost from the dockerClientConfig.
See the discussion from #1181
Activity
kiview commentedon Feb 26, 2019
So after a little bit more investigation it seems running in side the docker build is not the problem, but the remote Docker daemon's host not exposing the Docker socket.
Not really, since the Ryuk container is already spawned on the correct daemon.
In which kind of environment are you running this? Some special CI?
mariusneo commentedon Feb 26, 2019
I am running the scenario on a homemade CI environment at the companwhere I am employed.
Indeed it is so. The operations engineer handling the remote docker daemon machine was saying that
dockerdexposes either tcp or unix sock, reason why the dockerd on the remote machine is only accessible overtcpNow I am reading the page
https://docs.docker.com/engine/reference/commandline/dockerd/
and see that it is though possible to expose both tcp and unix sockets for the
dockerd.I'm getting back with a reply tommorow whether this is just a misconfiguration on our home grown CI environment.
Thanks for the heads up and sorry for the false feature request.
bsideup commentedon Feb 26, 2019
mariusneo commentedon Mar 4, 2019
Hi guys, I've just tried to run the tests without disabling
ryuk(throughENV TESTCONTAINERS_RYUK_DISABLED="true") when the remote docker daemon has the unix socket-H unix:///var/run/docker.sock(along the tcp socket) active and the tests run successfully.This means that the issue i've reported is rather linked to our special CI environment.
Thanks again for the heads up.
Closing the invalid feature request.