We are basically creating Junit tests that test a Varnish configuration by using a rest client(rest assured) and a fake backend(wiremock)
The tests themselves play both roles, as a client and fake backend, and because of that Varnish is run inside a container exposing to it the host's port, in order to enable varnish -> wiremock communication.
This works perfectly without any problem in Mac but in Linux (where we have our Jenkins) fails with the following stacktrace
19:14:50 [MShield] Running shell script
19:14:50 + docker run --privileged=true -u jenkins -v /var/lib/jenkins/workspace/MShield:/usr/src/mymaven -v /var/lib/jenkins/.m2:/home/jenkins/.m2 -v /var/run/docker.sock:/var/run/docker.sock -e TESTCONTAINERS_RYUK_DISABLED=true -w /usr/src/mymaven marfeeljava:latest mvn test
19:14:52 [INFO] Scanning for projects...
19:14:52 [WARNING]
19:14:52 [WARNING] Some problems were encountered while building the effective model for com.marfeel:MShieldTesting:jar:1.0-SNAPSHOT
19:14:52 [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 21, column 21
19:14:52 [WARNING]
19:14:52 [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
19:14:52 [WARNING]
19:14:52 [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
19:14:52 [WARNING]
19:14:52 [INFO] ------------------------------------------------------------------------
19:14:52 [INFO] Reactor Build Order:
19:14:52 [INFO]
19:14:52 [INFO] MarfeelMShield
19:14:52 [INFO] MShieldTesting
19:14:52 [INFO]
19:14:52 [INFO] ------------------------------------------------------------------------
19:14:52 [INFO] Building MarfeelMShield 1.0-SNAPSHOT
19:14:52 [INFO] ------------------------------------------------------------------------
19:14:52 [INFO]
19:14:52 [INFO] ------------------------------------------------------------------------
19:14:52 [INFO] Building MShieldTesting 1.0-SNAPSHOT
19:14:52 [INFO] ------------------------------------------------------------------------
19:14:52 [INFO]
19:14:52 [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MShieldTesting ---
19:14:52 [INFO] Using 'UTF-8' encoding to copy filtered resources.
19:14:52 [INFO] Copying 3 resources
19:14:52 [INFO]
19:14:52 [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MShieldTesting ---
19:14:52 [INFO] No sources to compile
19:14:52 [INFO]
19:14:52 [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MShieldTesting ---
19:14:52 [INFO] Using 'UTF-8' encoding to copy filtered resources.
19:14:52 [INFO] Copying 12 resources
19:14:52 [INFO]
19:14:52 [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MShieldTesting ---
19:14:52 [INFO] Changes detected - recompiling the module!
19:14:52 [INFO] Compiling 2 source files to /usr/src/mymaven/MShieldTesting/target/test-classes
19:14:53 [WARNING] /usr/src/mymaven/MShieldTesting/src/test/java/com/marfeel/mshield/MShieldVarnishITTest.java: /usr/src/mymaven/MShieldTesting/src/test/java/com/marfeel/mshield/MShieldVarnishITTest.java uses unchecked or unsafe operations.
19:14:53 [WARNING] /usr/src/mymaven/MShieldTesting/src/test/java/com/marfeel/mshield/MShieldVarnishITTest.java: Recompile with -Xlint:unchecked for details.
19:14:53 [INFO]
19:14:53 [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MShieldTesting ---
19:14:53 [INFO] Surefire report directory: /usr/src/mymaven/MShieldTesting/target/surefire-reports
19:14:53
19:14:53 -------------------------------------------------------
19:14:53 T E S T S
19:14:53 -------------------------------------------------------
19:14:53 Running com.marfeel.mshield.MShieldNginxITTest
19:14:53 18:14:53.656 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Will use 'okhttp' transport
19:14:54 18:14:53.990 [main] INFO org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy - Found docker client settings from environment
19:14:54 18:14:54.011 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with Environment variables, system properties and defaults. Resolved:
19:14:54 dockerHost=unix:///var/run/docker.sock
19:14:54 apiVersion='{UNKNOWN_VERSION}'
19:14:54 registryUrl='https://index.docker.io/v1/'
19:14:54 registryUsername='jenkins'
19:14:54 registryPassword='null'
19:14:54 registryEmail='null'
19:14:54 dockerConfig='DefaultDockerClientConfig[dockerHost=unix:///var/run/docker.sock,registryUsername=jenkins,registryPassword=<null>,registryEmail=<null>,registryUrl=https://index.docker.io/v1/,dockerConfigPath=/home/jenkins/.docker,sslConfig=<null>,apiVersion={UNKNOWN_VERSION},dockerConfig=<null>]'
19:14:54
19:14:54 18:14:54.246 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: alpine:3.5, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
19:14:55 18:14:55.168 [main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is 172.17.0.1
19:14:55 18:14:55.271 [main] INFO org.testcontainers.DockerClientFactory - Connected to docker:
19:14:55 Server Version: 18.06.1-ce
19:14:55 API Version: 1.38
19:14:55 Operating System: Ubuntu 16.04.5 LTS
19:14:55 Total Memory: 128822 MB
19:14:55 [37m[1m?? Checking the system...[0m[0m
19:14:55 [32m? Docker version should be at least 1.6.0[0m
19:14:55 18:14:55.386 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: alpine:3.5, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
19:14:56 [32m? Docker environment should have more than 2GB free disk space[0m
19:14:56 18:14:56.408 [main] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Pulling docker image: quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088. Please be patient; this may take some time but only needs to be done once.
19:14:56 18:14:56.410 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: quay.io/testcontainers/sshd:latest, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
19:14:57 18:14:57.659 [main] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Creating container for image: quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088
19:14:57 18:14:57.660 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
19:14:57 18:14:57.747 [main] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Starting container with ID: 5d92dd595dcbdf27685f0e68882543fce3c5095323e01df5364eb7db60d54cb8
19:14:58 18:14:58.141 [main] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Container quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088 is starting: 5d92dd595dcbdf27685f0e68882543fce3c5095323e01df5364eb7db60d54cb8
19:16:05 18:15:58.232 [main] ERROR docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Could not start container
19:16:05 org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1 ports: [32774] should be listening)
19:16:05 at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:47)
19:16:05 at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
19:16:05 at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:23)
19:16:05 at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
19:16:05 at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:591)
19:16:05 at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:263)
19:16:05 at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:216)
19:16:05 at org.testcontainers.containers.GenericContainer$$Lambda$53/515184459.call(Unknown Source)
19:16:05 at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
19:16:05 at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:214)
19:16:05 at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:203)
19:16:05 at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:39)
19:16:05 at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:24)
19:16:05 at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:60)
19:16:05 at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:11)
19:16:05 at com.marfeel.mshield.MShieldNginxITTest.<clinit>(MShieldNginxITTest.java:21)
19:16:05 at sun.misc.Unsafe.ensureClassInitialized(Native Method)
19:16:05 at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
19:16:05 at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
19:16:05 at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
19:16:05 at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
19:16:05 at java.lang.reflect.Field.get(Field.java:393)
19:16:05 at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
19:16:05 at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
19:16:05 at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
19:16:05 at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
19:16:05 at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
19:16:05 at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
19:16:05 at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
19:16:05 at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
19:16:05 at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
19:16:05 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:16:05 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
19:16:05 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
19:16:05 at java.lang.reflect.Method.invoke(Method.java:497)
19:16:05 at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
19:16:05 at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
19:16:05 at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
19:16:05 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
19:16:05 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
19:16:05 18:15:58.233 [main] ERROR docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Container log output (if any) will follow:
19:16:05 18:15:58.238 [tc-okhttp-stream-452121674] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - STDERR: chpasswd: password for 'root' changed
19:16:05 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 64.836 sec <<< FAILURE!
19:16:05 com.marfeel.mshield.MShieldNginxITTest Time elapsed: 64.834 sec <<< ERROR!
19:16:05 java.lang.ExceptionInInitializerError
19:16:05 at sun.misc.Unsafe.ensureClassInitialized(Native Method)
19:16:05 at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
19:16:05 at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
19:16:05 at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
19:16:05 at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
19:16:05 at java.lang.reflect.Field.get(Field.java:393)
19:16:05 at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
19:16:05 at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
19:16:05 at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
19:16:05 at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
19:16:05 at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
19:16:05 at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
19:16:05 at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
19:16:05 at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
19:16:05 at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
19:16:05 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:16:05 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
19:16:05 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
19:16:05 at java.lang.reflect.Method.invoke(Method.java:497)
19:16:05 at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
19:16:05 at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
19:16:05 at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
19:16:05 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
19:16:05 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
19:16:05 Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed
19:16:05 at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:221)
19:16:05 at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:203)
19:16:05 at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:39)
19:16:05 at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:24)
19:16:05 at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:60)
19:16:05 at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:11)
19:16:05 at com.marfeel.mshield.MShieldNginxITTest.<clinit>(MShieldNginxITTest.java:21)
19:16:05 ... 24 more
19:16:05 Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
19:16:05 at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:83)
19:16:05 at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:214)
19:16:05 ... 30 more
19:16:05 Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
19:16:05 at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:286)
19:16:05 at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:216)
19:16:05 at org.testcontainers.containers.GenericContainer$$Lambda$53/515184459.call(Unknown Source)
19:16:05 at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
19:16:05 ... 31 more
19:16:05 Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1 ports: [32774] should be listening)
19:16:05 at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:47)
19:16:05 at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
19:16:05 at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:23)
19:16:05 at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
19:16:05 at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:591)
19:16:05 at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:263)
19:16:05 ... 34 more
19:16:05
More info
Host's docker.sock permissions are as follow
srw-rw---- 1 root docker 0 Sep 12 10:22 /var/run/docker.sock
The user that runs the docker is jenkins, who belongs to the docker group, and because of that we are using a custom maven:3.2.5-jdk-8 named marfeeljava, based on the following Dockerfile
FROM maven:3.2.5-jdk-8
RUN groupadd -g 999 docker && \
useradd -d /home/jenkins -m -r -u 1004 -g docker jenkins
The command run is the following and as said it works perfectly in my Mac :|
docker run --privileged=true -u jenkins -v "$PWD":/usr/src/mymaven -v "$HOME/.m2":/home/jenkins/.m2 -v /var/run/docker.sock:/var/run/docker.sock -e TESTCONTAINERS_RYUK_DISABLED=true -w /usr/src/mymaven marfeeljava:latest mvn test
The sshd container is up and running, but it seems that testcontainers is unable to use it
The following code snippet shows how we initialize all the needed stuff
static {
Testcontainers.exposeHostPorts(BACKEND_PORT);
}
@ClassRule
public static WireMockClassRule wireMockRule = new WireMockClassRule(BACKEND_PORT);
@Rule
public WireMockClassRule instanceRule = wireMockRule;
private static ToStringConsumer OUTPUT_CONSUMER = new ToStringConsumer();
private static String CONTAINER_ADDRESS;
private static Integer CONTAINER_PORT;
@ClassRule
public static GenericContainer varnish = new GenericContainer(
new ImageFromDockerfile("mshield", false)
.withFileFromClasspath("Dockerfile", "Dockerfile")
.withFileFromClasspath("start.sh", "start.sh")
.withFileFromClasspath("default.vcl", "default.vcl")
.withFileFromClasspath("testVha.vcl", "testVha.vcl")
.withFileFromClasspath("testBackendFetch.vcl", "testBackendFetch.vcl")
.withFileFromClasspath("vha_40.vcl", "vha_40.vcl")
.withFileFromClasspath("docker-entrypoint.sh", "docker-entrypoint.sh"))
.withExposedPorts(6081).withEnv("hostPort",String.valueOf(BACKEND_PORT));
@Before
public void setUp() throws Exception {
//varnish.followOutput(OUTPUT_CONSUMER, OutputFrame.OutputType.STDOUT);
CONTAINER_ADDRESS = varnish.getContainerIpAddress();
CONTAINER_PORT = varnish.getMappedPort(6081);
}
Any hint will be highly appreciated
Hi @jordillachmrf!
I will try to analyze the issue, but before that, may I ask you why you have TESTCONTAINERS_RYUK_DISABLED=true?
When running with ryuk
```
14:15:46 13:15:46.096 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Will use 'okhttp' transport
14:15:46 13:15:46.454 [main] INFO org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy - Found docker client settings from environment
14:15:46 13:15:46.466 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with Environment variables, system properties and defaults. Resolved:
14:15:46 dockerHost=unix:///var/run/docker.sock
14:15:46 apiVersion='{UNKNOWN_VERSION}'
14:15:46 registryUrl='https://index.docker.io/v1/'
14:15:46 registryUsername='jenkins'
14:15:46 registryPassword='null'
14:15:46 registryEmail='null'
14:15:46 dockerConfig='DefaultDockerClientConfig[dockerHost=unix:///var/run/docker.sock,registryUsername=jenkins,registryPassword=
14:15:46
14:15:46 13:15:46.684 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: alpine:3.5, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
14:15:47 13:15:47.551 [main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is 172.17.0.1
14:15:47 13:15:47.644 [main] INFO org.testcontainers.DockerClientFactory - Connected to docker:
14:15:47 Server Version: 18.06.1-ce
14:15:47 API Version: 1.38
14:15:47 Operating System: Ubuntu 16.04.5 LTS
14:15:47 Total Memory: 128822 MB
14:15:48 13:15:47.763 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: quay.io/testcontainers/ryuk:0.2.2, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
14:16:20 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 32.451 sec <<< FAILURE!
14:16:20 com.marfeel.mshield.MShieldNginxITTest Time elapsed: 32.451 sec <<< ERROR!
14:16:20 java.lang.ExceptionInInitializerError
14:16:20 at sun.misc.Unsafe.ensureClassInitialized(Native Method)
14:16:20 at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
14:16:20 at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
14:16:20 at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
14:16:20 at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
14:16:20 at java.lang.reflect.Field.get(Field.java:393)
14:16:20 at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
14:16:20 at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
14:16:20 at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
14:16:20 at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
14:16:20 at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
14:16:20 at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
14:16:20 at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
14:16:20 at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
14:16:20 at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
14:16:20 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:16:20 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:16:20 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:16:20 at java.lang.reflect.Method.invoke(Method.java:497)
14:16:20 at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
14:16:20 at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
14:16:20 at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
14:16:20 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
14:16:20 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
14:16:20 Caused by: java.lang.IllegalStateException: Can not connect to Ryuk
14:16:20 at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:148)
14:16:20 at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:125)
14:16:20 at org.testcontainers.containers.GenericContainer.
14:16:20 at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:30)
14:16:20 at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:24)
14:16:20 at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:60)
14:16:20 at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:11)
14:16:20 at com.marfeel.mshield.MShieldNginxITTest.
14:16:20 ... 24 more
14:16:20
14:16:20 Running com.marfeel.mshield.MShieldVarnishITTest
14:16:20 13:16:18.444 [main] INFO org.mortbay.log - Logging to Logger[org.mortbay.log] via org.mortbay.log.Slf4jLog
14:16:20 13:16:18.668 [main] INFO docker[mshield] - Creating container for image: mshield
14:16:20 13:16:18.669 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: mshield:latest, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
14:16:20 13:16:18.762 [main] INFO docker[mshield] - Starting container with ID: ecf364fcc7bd211bf482893d1e5a8ca196036b900bee9d0a9a805f65ad6d930f
14:16:20 13:16:19.165 [main] INFO docker[mshield] - Container mshield is starting: ecf364fcc7bd211bf482893d1e5a8ca196036b900bee9d0a9a805f65ad6d930f
Post stage
14:17:27 13:17:19.194 [main] ERROR docker[mshield] - Could not start container
14:17:27 org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1 ports: [32781] should be listening)
14:17:27 at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:47)
14:17:27 at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
14:17:27 at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:23)
14:17:27 at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
14:17:27 at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:591)
14:17:27 at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:263)
14:17:27 at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:216)
14:17:27 at org.testcontainers.containers.GenericContainer$$Lambda$52/380812044.call(Unknown Source)
14:17:27 at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
14:17:27 at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:214)
14:17:27 at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:203)
14:17:27 at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:723)
14:17:27 at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
14:17:27 at com.github.tomakehurst.wiremock.junit.WireMockClassRule$1.evaluate(WireMockClassRule.java:75)
14:17:27 at org.junit.rules.RunRules.evaluate(RunRules.java:20)
14:17:27 at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
14:17:27 at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
14:17:27 at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
14:17:27 at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
14:17:27 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:17:27 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:17:27 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:17:27 at java.lang.reflect.Method.invoke(Method.java:497)
14:17:27 at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
14:17:27 at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
14:17:27 at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
14:17:27 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
14:17:27 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
@jordillachmrf so, apparently you have some connectivity issues.
Could you please debug if it's even possible to access 172.17.0.1 from inside the container?
From within the container that runs the test I can see the host
```
root@montargull ~ # docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cd602bb6eec2 marfeeljava:latest "mvn test" About a minute ago Up About a minute dazzling_northcutt
root@montargull ~ # docker exec -it cd602bb6eec2 ping 172.17.0.1
PING 172.17.0.1 (172.17.0.1): 56 data bytes
64 bytes from 172.17.0.1: icmp_seq=0 ttl=64 time=0.097 ms
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.084 ms
64 bytes from 172.17.0.1: icmp_seq=2 ttl=64 time=0.063 ms
@jordillachmrf do you see Ryuk running, or does it exit immediately? (try docker ps -a)
Ryuk is there for a while (less that a minute)
```
14696dfb271 quay.io/testcontainers/ryuk:0.2.2 "/app" 32 seconds ago Up 31 seconds 0.0.0.0:32822->8080/tcp testcontainers-ryuk-9e3c045a-1374-482d-9a96-0aca8ebd2e78
Could you please try to curl it from your container? Thanks for checking!
FYI you can also send some data with nc:
https://github.com/testcontainers/moby-ryuk
Also, please check the logs of Ryuk, maybe it will show something
This is the log from ryuk container, and a curl from the host instance
```
root@montargull ~ # docker logs de601f107844
2019/02/08 13:42:06 Starting on port 8080...
root@montargull ~ # curl -GET http://172.17.0.3:8080
ACK
ACK
ACK
Ok, it seems to be listening and all good. Now I see (in your last log) that actually mshield container is failing to start. Try checking his logs.
Varnish(which resides inside mshield container) is not able to start because it has a default backend, host.docker.internal:9090
This host is resolved based on /etc/hosts changes that we made during startup with the following .sh
HOST_DOMAIN="host.testcontainers.internal"
HOST_IP=$(ping -q -c1 $HOST_DOMAIN |awk 'NR==1{gsub(/\(|\)/,"",$3);print $3}')
echo -e "$HOST_IP\thost.docker.internal" >> /etc/hosts
But when ryuk is enabled the magick done by testconainers with host.testcontainers.internal does not work and thus varnish is unable to start
And because of this, we have the following output
14:55:24 Caused by: java.lang.IllegalStateException: Can not connect to Ryuk
14:55:24 at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:148)
14:55:24 at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:125)
14:55:24 at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:142)
14:55:24 at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:30)
14:55:24 at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:24)
14:55:24 at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:60)
14:55:24 at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:11)
14:55:24 at com.marfeel.mshield.MShieldNginxITTest.<clinit>(MShieldNginxITTest.java:24)
14:55:24 ... 24 more
14:55:24
14:55:24 Running com.marfeel.mshield.MShieldVarnishITTest
14:55:24 13:55:22.654 [main] INFO org.mortbay.log - Logging to Logger[org.mortbay.log] via org.mortbay.log.Slf4jLog
14:55:24 13:55:22.895 [main] INFO docker[mshield] - Creating container for image: mshield
14:55:24 13:55:22.896 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: mshield:latest, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
14:55:24 13:55:23.004 [main] INFO docker[mshield] - Starting container with ID: e4ec27478d62859d0491813fb1dc11ae82c667d451da3254f1aa856820b24229
14:55:24 13:55:23.340 [main] INFO docker[mshield] - Container mshield is starting: e4ec27478d62859d0491813fb1dc11ae82c667d451da3254f1aa856820b24229
Post stage
14:56:31 13:56:23.358 [main] ERROR docker[mshield] - Could not start container
14:56:31 org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1 ports: [32829] should be listening)
14:56:31 at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:47)
14:56:31 at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
14:56:31 at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:23)
14:56:31 at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
14:56:31 at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:591)
14:56:31 at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:263)
14:56:31 at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:216)
14:56:31 at org.testcontainers.containers.GenericContainer$$Lambda$52/380812044.call(Unknown Source)
14:56:31 at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
14:56:31 at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:214)
14:56:31 at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:203)
14:56:31 at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:723)
14:56:31 at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
14:56:31 at com.github.tomakehurst.wiremock.junit.WireMockClassRule$1.evaluate(WireMockClassRule.java:75)
14:56:31 at org.junit.rules.RunRules.evaluate(RunRules.java:20)
14:56:31 at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
14:56:31 at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
14:56:31 at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
14:56:31 at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
14:56:31 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:56:31 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
14:56:31 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
14:56:31 at java.lang.reflect.Method.invoke(Method.java:497)
14:56:31 at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
14:56:31 at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
14:56:31 at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
14:56:31 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
14:56:31 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
14:56:31 13:56:23.359 [main] ERROR docker[mshield] - Container log output (if any) will follow:
14:56:31 13:56:23.364 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDOUT: /etc/varnish is not empty. We are ok to go.
14:56:31 13:56:23.364 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDOUT: /etc/varnish/secret exists. We are ok to go.
14:56:31 13:56:23.364 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: varnishd (varnish-plus-6.0.1r5 revision 87748e9eb3054a0395e8d0df6e06306b5782a089)
14:56:31 13:56:23.365 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: Copyright (c) 2006 Verdens Gang AS
14:56:31 13:56:23.365 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: Copyright (c) 2006-2015 Varnish Software AS
14:56:31 13:56:23.365 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: ping: host.testcontainers.internal: Name or service not known
14:56:31 13:56:23.366 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: Error:
14:56:31 13:56:23.366 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: Message from VCC-compiler:
14:56:31 13:56:23.366 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: Backend host '"host.docker.internal"' could not be resolved to an IP address:
14:56:31 13:56:23.366 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: Name or service not known
14:56:31 13:56:23.367 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: (Sorry if that error message is gibberish.)
14:56:31 13:56:23.367 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: ('/etc/varnish/default.vcl' Line 28 Pos 13)
14:56:31 13:56:23.367 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: .host = "host.docker.internal";
14:56:31 13:56:23.367 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: ------------######################-
14:56:31 13:56:23.367 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR:
14:56:31 13:56:23.368 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR:
14:56:31 13:56:23.368 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: In backend specification starting at:
14:56:31 13:56:23.368 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: ('/etc/varnish/default.vcl' Line 27 Pos 1)
14:56:31 13:56:23.368 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: backend default {
14:56:31 13:56:23.369 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: #######----------
14:56:31 13:56:23.369 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR:
14:56:31 13:56:23.369 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: Running VCC-compiler failed, exited with 2
14:56:31 13:56:23.369 [tc-okhttp-stream-1215904751] INFO docker[mshield] - STDERR: VCL compilation failed
14:56:31 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 60.98 sec <<< FAILURE!
When ryuk is disabled mshield container starts ok
root@montargull ~ # docker logs 7c23fc2b66bf
/etc/varnish is not empty. We are ok to go.
/etc/varnish/secret exists. We are ok to go.
varnishd (varnish-plus-6.0.1r5 revision 87748e9eb3054a0395e8d0df6e06306b5782a089)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2015 Varnish Software AS
Debug: Version: varnish-plus-6.0.1r5 revision 87748e9eb3054a0395e8d0df6e06306b5782a089
Debug: Platform: Linux,4.13.0-36-generic,x86_64,-junix,-smalloc,-sdefault,-hcritbit
Debug: Child (73) Started
Info: Child (73) said Child starts
By the way I think that all the containers can see each other
```
root@montargull ~ # docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7c23fc2b66bf mshield "start-varnish" Less than a second ago Up Less than a second 0.0.0.0:32831->6081/tcp confident_stallman
98008678c0ee quay.io/testcontainers/sshd "sh -c 'echo "root:$…" About a minute ago Up About a minute 0.0.0.0:32830->22/tcp sad_varahamihira
7303c27f4083 marfeeljava:latest "mvn test" About a minute ago Up About a minute vigorous_edison
root@montargull ~ # docker exec -it 7c23fc2b66bf ping 172.17.0.3
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_seq=1 ttl=64 time=0.080 ms
64 bytes from 172.17.0.3: icmp_seq=2 ttl=64 time=0.074 ms
^C
--- 172.17.0.3 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1003ms
rtt min/avg/max/mdev = 0.074/0.077/0.080/0.003 ms
root@montargull ~ # docker exec -it 7c23fc2b66bf ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.113 ms
64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.073 ms
^C
--- 172.17.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1016ms
rtt min/avg/max/mdev = 0.073/0.093/0.113/0.020 ms
root@montargull ~ # docker exec -it 7c23fc2b66bf ping 172.17.0.1
PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data.
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.105 ms
64 bytes from 172.17.0.1: icmp_seq=2 ttl=64 time=0.063 ms
Backend host '"host.docker.internal"'
double quoting makes me thing that the host in Varnish is set incorrectly. Also, it is host.testcontainers.internal, not host.docker.internal:
https://www.testcontainers.org/features/networking/#exposing-host-ports-to-the-container
HOST_DOMAIN="host.testcontainers.internal"
HOST_IP=$(ping -q -c1 $HOST_DOMAIN |awk 'NR==1{gsub(/\(|\)/,"",$3);print $3}')
echo -e "$HOST_IP\thost.docker.internal" >> /etc/hosts
We set in /etc/hosts the ip value of host.testcontainers.internal to host.docker.internal
As said this part works fine when ryuk is disabled, and of course in my local env(Mac) with docker in docker, do not ask me why :)
The difference in my local env and this docker in docker in linux is that in the latter I can not see the portforwarded connections in the sshd container
on Mac, there is a magical DNS name "host.docker.internal" by Docker for Mac, and I guess your "trick" never gets checked.
However, There is no such on Linux, and it fails.
So, Testcontainers works, not your trick, it seems :)
This is the list of containers that we have
root@montargull ~ # docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fae2897fcb22 mshield "start-varnish" 2 seconds ago Up 1 second 0.0.0.0:32833->6081/tcp competent_elbakyan
7309d7884ca5 quay.io/testcontainers/sshd "sh -c 'echo \"root:$…" About a minute ago Up About a minute 0.0.0.0:32832->22/tcp blissful_bassi
088dfe2ab991 marfeeljava:latest "mvn test" About a minute ago Up About a minute fervent_tesla
98008678c0ee quay.io/testcontainers/sshd "sh -c 'echo \"root:$…" 34 minutes ago Up 34 minutes 0.0.0.0:32830->22/tcp sad_varahamihira
We can verify the outcome of the trick in /etc/hosts
root@montargull ~ # docker exec -it fae2897fcb22 cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.4 host.testcontainers.internal
172.17.0.5 fae2897fcb22
172.17.0.4 host.docker.internal
Varnish is up and running but is unable to access it's default backend because the portforwarding to host port 9090 is not working
root@montargull ~ # docker exec -it fae2897fcb22 curl -XGET http://localhost:6081/
<!DOCTYPE html>
<html>
<head>
<title>503 Backend fetch failed</title>
</head>
<body>
<h1>Error 503 Backend fetch failed</h1>
<p>Backend fetch failed</p>
<h3>Guru Meditation:</h3>
<p>XID: 32771</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>
Mmmm ... host.testcontainers.internal is pointing to "mvn test"(172.17.0.4) container and not the real host one(172.17.0.1), I guess that this is ok given that in the "mvn test" container is where wiremock is listening at 9090 port
@jordillachmrf does your app on the host listens on "localhost" or specific IP? We forward to "localhost":
https://github.com/testcontainers/testcontainers-java/blob/dabe7dab141fef9e975bf8e852be9b58d3fbd177/core/src/main/java/org/testcontainers/containers/PortForwardingContainer.java#L60
I have double check that by using host.xxx.internal everything works "well"( I mean that the trick seems to work fine), and it does
And yes, by looking at wiremock code, localhost is used, from WireMockClassRule
WireMock.configureFor("localhost", port());
I just tried to run this test inside a container and it worked perfectly fine.
If you can run it in your infrastructure (./gradlew --no-daemon testcontainers:test --tests '*ExposedHostTest') and verify that it either fails or not, it will help a lot.
Maybe I could share the project with you if you think that this could help
When running mvn test directly works fine, the same as my tests but running docker in docker it fails
root@collfred /var/lib/jenkins/workspace/MShield # docker run -u jenkins -v "$PWD":/usr/src/mymaven -v "$HOME/.m2":/home/jenkins/.m2 -v /var/run/docker.sock:/var/run/docker.sock -w /usr/src/mymaven marfeeljava:latest mvn test -Dtest=ExposedHostTest
+[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.marfeel:MShieldTesting:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 21, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] MarfeelMShield
[INFO] MShieldTesting
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MarfeelMShield 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MShieldTesting 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MShieldTesting ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MShieldTesting ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MShieldTesting ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 12 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MShieldTesting ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /usr/src/mymaven/MShieldTesting/target/test-classes
[WARNING] /usr/src/mymaven/MShieldTesting/src/test/java/com/marfeel/mshield/MShieldVarnishITTest.java: Some input files use unchecked or unsafe operations.
[WARNING] /usr/src/mymaven/MShieldTesting/src/test/java/com/marfeel/mshield/MShieldVarnishITTest.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MShieldTesting ---
[INFO] Surefire report directory: /usr/src/mymaven/MShieldTesting/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.marfeel.mshield.ExposedHostTest
16:23:02.020 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Will use 'okhttp' transport
16:23:02.386 [main] INFO org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy - Found docker client settings from environment
16:23:02.410 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with Environment variables, system properties and defaults. Resolved:
dockerHost=unix:///var/run/docker.sock
apiVersion='{UNKNOWN_VERSION}'
registryUrl='https://index.docker.io/v1/'
registryUsername='jenkins'
registryPassword='null'
registryEmail='null'
dockerConfig='DefaultDockerClientConfig[dockerHost=unix:///var/run/docker.sock,registryUsername=jenkins,registryPassword=<null>,registryEmail=<null>,registryUrl=https://index.docker.io/v1/,dockerConfigPath=/home/jenkins/.docker,sslConfig=<null>,apiVersion={UNKNOWN_VERSION},dockerConfig=<null>]'
16:23:02.655 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: alpine:3.5, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
16:23:03.516 [main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is 172.17.0.1
16:23:03.608 [main] INFO org.testcontainers.DockerClientFactory - Connected to docker:
Server Version: 18.06.1-ce
API Version: 1.38
Operating System: Ubuntu 16.04.5 LTS
Total Memory: 128822 MB
16:23:03.741 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: quay.io/testcontainers/ryuk:0.2.2, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 32.497 sec <<< FAILURE!
com.marfeel.mshield.ExposedHostTest Time elapsed: 32.495 sec <<< ERROR!
java.lang.IllegalStateException: Can not connect to Ryuk
at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:148)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:125)
at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:142)
at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:30)
at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:24)
at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:60)
at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:11)
at com.marfeel.mshield.ExposedHostTest.setUpClass(ExposedHostTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Results :
Tests in error:
com.marfeel.mshield.ExposedHostTest: Can not connect to Ryuk
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
If ryuk is disabled the sshd container times out
root@collfred /var/lib/jenkins/workspace/MShield # docker run -u jenkins -v "$PWD":/usr/src/mymaven -v "$HOME/.m2":/home/jenkins/.m2 -v /var/run/docker.sock:/var/run/docker.sock -e TESTCONTAINERS_RYUK_DISABLED=true -w /usr/src/mymaven marfeeljava:latest mvn test -Dtest=ExposedHostTest
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.marfeel:MShieldTesting:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 21, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] MarfeelMShield
[INFO] MShieldTesting
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MarfeelMShield 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MShieldTesting 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MShieldTesting ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MShieldTesting ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MShieldTesting ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 12 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MShieldTesting ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MShieldTesting ---
[INFO] Surefire report directory: /usr/src/mymaven/MShieldTesting/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.marfeel.mshield.ExposedHostTest
16:27:49.032 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Will use 'okhttp' transport
16:27:49.311 [main] INFO org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy - Found docker client settings from environment
16:27:49.323 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with Environment variables, system properties and defaults. Resolved:
dockerHost=unix:///var/run/docker.sock
apiVersion='{UNKNOWN_VERSION}'
registryUrl='https://index.docker.io/v1/'
registryUsername='jenkins'
registryPassword='null'
registryEmail='null'
dockerConfig='DefaultDockerClientConfig[dockerHost=unix:///var/run/docker.sock,registryUsername=jenkins,registryPassword=<null>,registryEmail=<null>,registryUrl=https://index.docker.io/v1/,dockerConfigPath=/home/jenkins/.docker,sslConfig=<null>,apiVersion={UNKNOWN_VERSION},dockerConfig=<null>]'
16:27:49.489 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: alpine:3.5, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
16:27:50.334 [main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is 172.17.0.1
16:27:50.388 [main] INFO org.testcontainers.DockerClientFactory - Connected to docker:
Server Version: 18.06.1-ce
API Version: 1.38
Operating System: Ubuntu 16.04.5 LTS
Total Memory: 128822 MB
?? Checking the system...
? Docker version should be at least 1.6.0
16:27:50.485 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: alpine:3.5, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
? Docker environment should have more than 2GB free disk space
16:27:51.380 [main] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Pulling docker image: quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088. Please be patient; this may take some time but only needs to be done once.
16:27:51.382 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: quay.io/testcontainers/sshd:latest, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
16:27:52.615 [main] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Creating container for image: quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088
16:27:52.616 [main] WARN org.testcontainers.utility.RegistryAuthLocator - Failure when attempting to lookup auth config (dockerImageName: quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088, configFile: /home/jenkins/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/jenkins/.docker/config.json (No such file or directory)
16:27:52.696 [main] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Starting container with ID: 6361a1c35bdf226fe0e22e14e923dde90e875bcfcb1c093c453756c6a2454778
16:27:53.063 [main] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Container quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088 is starting: 6361a1c35bdf226fe0e22e14e923dde90e875bcfcb1c093c453756c6a2454778
16:28:53.126 [main] ERROR docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Could not start container
org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1 ports: [32800] should be listening)
at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:47)
at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:23)
at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:591)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:263)
at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:216)
at org.testcontainers.containers.GenericContainer$$Lambda$54/1047460013.call(Unknown Source)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:214)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:203)
at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:39)
at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:24)
at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:60)
at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:11)
at com.marfeel.mshield.ExposedHostTest.setUpClass(ExposedHostTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
16:28:53.127 [main] ERROR docker[quay.io/testcontainers/sshd@sha256:18aa92...] - Container log output (if any) will follow:
16:28:53.133 [tc-okhttp-stream-1652807864] INFO docker[quay.io/testcontainers/sshd@sha256:18aa92...] - STDERR: chpasswd: password for 'root' changed
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 64.392 sec <<< FAILURE!
com.marfeel.mshield.ExposedHostTest Time elapsed: 64.391 sec <<< ERROR!
org.testcontainers.containers.ContainerLaunchException: Container startup failed
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:221)
at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:203)
at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:39)
at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:24)
at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:60)
at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:11)
at com.marfeel.mshield.ExposedHostTest.setUpClass(ExposedHostTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:83)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:214)
... 28 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:286)
at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:216)
at org.testcontainers.containers.GenericContainer$$Lambda$54/1047460013.call(Unknown Source)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
... 29 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1 ports: [32800] should be listening)
at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:47)
at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
at org.testcontainers.containers.wait.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:23)
at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:591)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:263)
... 32 more
Results :
Tests in error:
com.marfeel.mshield.ExposedHostTest: Container startup failed
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.
This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.
Hi! I also encounter this exception, so I tried to follow your advice @bsideup and run ExposedHostTest, which fails. After further debugging, it seems to have got something to do with the pid, which cannot be parsed (see https://github.com/docker-java/docker-java/issues/1259).
com.fasterxml.jackson.databind.JsonMappingException: Numeric value (4294967295) out of range of int
at [Source: (okio.RealBufferedSource$1); line: 1, column: 506] (through reference chain: com.github.dockerjava.api.command.InspectExecResponse["Pid"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:353)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1711)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:290)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3077)
at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.get(OkHttpInvocationBuilder.java:100)
at com.github.dockerjava.core.exec.InspectExecCmdExec.execute(InspectExecCmdExec.java:27)
at com.github.dockerjava.core.exec.InspectExecCmdExec.execute(InspectExecCmdExec.java:13)
at com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
at com.github.dockerjava.core.command.InspectExecCmdImpl.exec(InspectExecCmdImpl.java:34)
at org.testcontainers.containers.ExecInContainerPattern.execInContainer(ExecInContainerPattern.java:85)
at org.testcontainers.containers.ExecInContainerPattern.execInContainer(ExecInContainerPattern.java:35)
at org.testcontainers.containers.wait.internal.InternalCommandPortListeningCheck.call(InternalCommandPortListeningCheck.java:42)
at org.testcontainers.containers.wait.internal.InternalCommandPortListeningCheck.call(InternalCommandPortListeningCheck.java:18)
at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.lambda$waitUntilReady$0(HostPortWaitStrategy.java:45)
at org.rnorth.ducttape.ratelimits.RateLimiter.getWhenReady(RateLimiter.java:51)
at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.lambda$waitUntilReady$1(HostPortWaitStrategy.java:45)
at org.rnorth.ducttape.unreliables.Unreliables.lambda$retryUntilTrue$1(Unreliables.java:101)
at org.rnorth.ducttape.unreliables.Unreliables.lambda$retryUntilSuccess$0(Unreliables.java:43)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Are you suggesting that 4294967295 is a PID? I got the exact same number in my error message.
See the link to the corresponding docker-java issue. This might shed some light on this problem.
At the end the problem is the one solved here https://github.com/testcontainers/testcontainers-java/issues/1277 , missing an entry in iptables
Most helpful comment
Hi! I also encounter this exception, so I tried to follow your advice @bsideup and run
ExposedHostTest, which fails. After further debugging, it seems to have got something to do with the pid, which cannot be parsed (see https://github.com/docker-java/docker-java/issues/1259).