testcontainers-java: Error: Could not start container

Hello everyone, I’m using testcontainers for E2E testing our Spring application. Everything was working, but one day on my PC (my colleague don’t have any problem) it started crashing. docker-compose up is working, I cleaned the whole docker cache, volumes, images, containers…, I cleaned all the gradle build, but I’m still receiving the following error:

2018-11-05 16:30:10.479 DEBUG 12682 --- [           main] o.t.utility.TestcontainersConfiguration  : Testcontainers configuration overrides will be loaded from file:/home/peter/.testcontainers.properties
2018-11-05 16:30:10.479 DEBUG 12682 --- [           main] o.t.utility.TestcontainersConfiguration  : Testcontainers configuration overrides loaded from TestcontainersConfiguration(properties={docker.client.strategy=org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy})
2018-11-05 16:30:10.497  INFO 12682 --- [           main] o.t.d.DockerClientProviderStrategy       : Loaded org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy from ~/.testcontainers.properties, will try it first
2018-11-05 16:30:10.514  INFO 12682 --- [           main] o.t.d.DockerClientProviderStrategy       : Will use 'okhttp' transport
2018-11-05 16:30:10.637 DEBUG 12682 --- [     ducttape-0] o.t.d.DockerClientProviderStrategy       : Pinging docker daemon...
2018-11-05 16:30:10.807  INFO 12682 --- [           main] tAndSystemPropertyClientProviderStrategy : Found docker client settings from environment
2018-11-05 16:30:10.819  INFO 12682 --- [           main] o.t.d.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='peter'
    registryPassword='null'
    registryEmail='null'
    dockerConfig='DefaultDockerClientConfig[dockerHost=unix:///var/run/docker.sock,registryUsername=peter,registryPassword=<null>,registryEmail=<null>,registryUrl=https://index.docker.io/v1/,dockerConfigPath=/home/peter/.docker,sslConfig=<null>,apiVersion={UNKNOWN_VERSION},dockerConfig=<null>]'

2018-11-05 16:30:10.820  INFO 12682 --- [           main] org.testcontainers.DockerClientFactory   : Docker host IP address is localhost
2018-11-05 16:30:10.932  INFO 12682 --- [           main] org.testcontainers.DockerClientFactory   : Connected to docker: 
  Server Version: 18.06.1-ce
  API Version: 1.38
  Operating System: Arch Linux
  Total Memory: 7850 MB
2018-11-05 16:30:10.950 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : Looking up auth config for image: quay.io/testcontainers/ryuk:0.2.2
2018-11-05 16:30:10.950 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : RegistryAuthLocator has configFile: /home/peter/.docker/config.json (exists) and commandPathPrefix: 
2018-11-05 16:30:10.953 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : registryName [quay.io] for dockerImageName [quay.io/testcontainers/ryuk:0.2.2]
2018-11-05 16:30:10.953 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : no matching Auth Configs - falling back to defaultAuthConfig [null]
2018-11-05 16:30:10.953 DEBUG 12682 --- [           main] o.t.d.a.AuthDelegatingDockerClientConfig : Effective auth config [null]
2018-11-05 16:30:14.422 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : Looking up auth config for image: quay.io/testcontainers/ryuk:0.2.2
2018-11-05 16:30:14.422 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : RegistryAuthLocator has configFile: /home/peter/.docker/config.json (exists) and commandPathPrefix: 
2018-11-05 16:30:14.423 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : registryName [quay.io] for dockerImageName [quay.io/testcontainers/ryuk:0.2.2]
2018-11-05 16:30:14.423 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : no matching Auth Configs - falling back to defaultAuthConfig [null]
2018-11-05 16:30:14.423 DEBUG 12682 --- [           main] o.t.d.a.AuthDelegatingDockerClientConfig : Effective auth config [null]
2018-11-05 16:30:14.977 DEBUG 12682 --- [containers-ryuk] o.testcontainers.utility.ResourceReaper  : Sending 'label=org.testcontainers%3Dtrue&label=org.testcontainers.sessionId%3D164abc25-0a92-4e4d-b6d4-c448d98e9a29' to Ryuk
2018-11-05 16:30:14.977 DEBUG 12682 --- [containers-ryuk] o.testcontainers.utility.ResourceReaper  : Received 'ACK' from Ryuk
2018-11-05 16:30:14.977  INFO 12682 --- [           main] org.testcontainers.DockerClientFactory   : Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
        ℹ︎ Checking the system...
        ✔ Docker version should be at least 1.6.0
        ✔ Docker environment should have more than 2GB free disk space
2018-11-05 16:30:15.039  INFO 12682 --- [           main] 🐳 [alpine/socat:latest]                 : Pulling docker image: alpine/socat:latest. Please be patient; this may take some time but only needs to be done once.
2018-11-05 16:30:15.039 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : Looking up auth config for image: alpine/socat:latest
2018-11-05 16:30:15.039 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : RegistryAuthLocator has configFile: /home/peter/.docker/config.json (exists) and commandPathPrefix: 
2018-11-05 16:30:15.039 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : registryName [index.docker.io] for dockerImageName [alpine/socat:latest]
2018-11-05 16:30:15.039 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : no matching Auth Configs - falling back to defaultAuthConfig [null]
2018-11-05 16:30:15.039 DEBUG 12682 --- [           main] o.t.d.a.AuthDelegatingDockerClientConfig : Effective auth config [null]
2018-11-05 16:30:17.356 DEBUG 12682 --- [containers-ryuk] o.testcontainers.utility.ResourceReaper  : Sending 'label=com.docker.compose.project%3Dyt7kd71uwxpq' to Ryuk
2018-11-05 16:30:17.358  INFO 12682 --- [           main] 🐳 [docker-compose]                      : Local Docker Compose is running command: pull
2018-11-05 16:30:17.369 DEBUG 12682 --- [           main] o.t.s.o.z.exec.ProcessExecutor           : Executing [docker-compose, pull] in /home/peter/Workspace/rds/rds-backend/out/test/resources with environment {COMPOSE_PROJECT_NAME=yt7kd71uwxpq, COMPOSE_FILE=/home/peter/Workspace/rds/rds-backend/out/test/resources/docker-compose.yml}.
2018-11-05 16:30:17.371 DEBUG 12682 --- [           main] o.t.s.o.z.exec.ProcessExecutor           : Started java.lang.UNIXProcess@48b2dbc4
2018-11-05 16:30:17.398 DEBUG 12682 --- [containers-ryuk] o.testcontainers.utility.ResourceReaper  : Received 'ACK' from Ryuk
2018-11-05 16:30:17.771 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling db        ... 
2018-11-05 16:30:17.771 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling uptime-db ... 
2018-11-05 16:30:19.149 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.150 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling uptime-db ... pulling from library/mysql
2018-11-05 16:30:19.182 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.183 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling db        ... pulling from timescale/timescaledb
2018-11-05 16:30:19.183 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.183 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling db        ... digest: sha256:48eac4ba55f6338015...
2018-11-05 16:30:19.183 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.183 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling db        ... status: image is up to date for t...
2018-11-05 16:30:19.184 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.185 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling db        ... done
2018-11-05 16:30:19.634 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.635 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling uptime-db ... digest: sha256:42bab37eda993e417c...
2018-11-05 16:30:19.635 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.635 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling uptime-db ... status: image is up to date for m...
2018-11-05 16:30:19.636 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.636 ERROR 12682 --- [       Thread-6] 🐳 [docker-compose]                      : Pulling uptime-db ... done
2018-11-05 16:30:19.685 DEBUG 12682 --- [           main] o.t.s.o.z.exec.WaitForProcess            : java.lang.UNIXProcess@48b2dbc4 stopped with exit code 0
2018-11-05 16:30:19.686 ERROR 12682 --- [           main] 🐳 [docker-compose]                      : 
2018-11-05 16:30:19.687  INFO 12682 --- [           main] 🐳 [docker-compose]                      : Docker Compose has finished running
2018-11-05 16:30:19.687  INFO 12682 --- [           main] 🐳 [docker-compose]                      : Local Docker Compose is running command: up -d
2018-11-05 16:30:19.687 DEBUG 12682 --- [           main] o.t.s.o.z.exec.ProcessExecutor           : Executing [docker-compose, up, -d] in /home/peter/Workspace/rds/rds-backend/out/test/resources with environment {COMPOSE_PROJECT_NAME=yt7kd71uwxpq, COMPOSE_FILE=/home/peter/Workspace/rds/rds-backend/out/test/resources/docker-compose.yml}.
2018-11-05 16:30:19.688 DEBUG 12682 --- [           main] o.t.s.o.z.exec.ProcessExecutor           : Started java.lang.UNIXProcess@66e1b2a
2018-11-05 16:30:19.943 ERROR 12682 --- [       Thread-8] 🐳 [docker-compose]                      : Creating network "yt7kd71uwxpq_default" with the default driver
2018-11-05 16:30:20.050 ERROR 12682 --- [       Thread-8] 🐳 [docker-compose]                      : Creating yt7kd71uwxpq_uptime-db_1_bee56e916398 ... 
2018-11-05 16:30:20.050 ERROR 12682 --- [       Thread-8] 🐳 [docker-compose]                      : Creating yt7kd71uwxpq_db_1_ed9e0d2e72c6        ... 
2018-11-05 16:30:20.488 ERROR 12682 --- [       Thread-8] 🐳 [docker-compose]                      : 
2018-11-05 16:30:20.488 ERROR 12682 --- [       Thread-8] 🐳 [docker-compose]                      : Creating yt7kd71uwxpq_uptime-db_1_bee56e916398 ... done
2018-11-05 16:30:20.521 ERROR 12682 --- [       Thread-8] 🐳 [docker-compose]                      : 
2018-11-05 16:30:20.521 ERROR 12682 --- [       Thread-8] 🐳 [docker-compose]                      : Creating yt7kd71uwxpq_db_1_ed9e0d2e72c6        ... done
2018-11-05 16:30:20.560 DEBUG 12682 --- [           main] o.t.s.o.z.exec.WaitForProcess            : java.lang.UNIXProcess@66e1b2a stopped with exit code 0
2018-11-05 16:30:20.561 ERROR 12682 --- [           main] 🐳 [docker-compose]                      : 
2018-11-05 16:30:20.561  INFO 12682 --- [           main] 🐳 [docker-compose]                      : Docker Compose has finished running
2018-11-05 16:30:20.563  INFO 12682 --- [           main] 🐳 [alpine/socat:latest]                 : Creating container for image: alpine/socat:latest
2018-11-05 16:30:20.563 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : Looking up auth config for image: alpine/socat:latest
2018-11-05 16:30:20.563 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : RegistryAuthLocator has configFile: /home/peter/.docker/config.json (exists) and commandPathPrefix: 
2018-11-05 16:30:20.563 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : registryName [index.docker.io] for dockerImageName [alpine/socat:latest]
2018-11-05 16:30:20.563 DEBUG 12682 --- [           main] o.t.utility.RegistryAuthLocator          : no matching Auth Configs - falling back to defaultAuthConfig [null]
2018-11-05 16:30:20.563 DEBUG 12682 --- [           main] o.t.d.a.AuthDelegatingDockerClientConfig : Effective auth config [null]
2018-11-05 16:30:20.598 ERROR 12682 --- [           main] 🐳 [alpine/socat:latest]                 : Could not start container

org.testcontainers.containers.ContainerLaunchException: Aborting attempt to link to container yt7kd71uwxpq_uptime-db_1 as it is not running
	at org.testcontainers.containers.GenericContainer.applyConfiguration(GenericContainer.java:492) [testcontainers-1.9.1.jar:na]
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:256) [testcontainers-1.9.1.jar:na]
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:237) [testcontainers-1.9.1.jar:na]
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76) ~[duct-tape-1.0.7.jar:na]
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:235) [testcontainers-1.9.1.jar:na]
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:220) [testcontainers-1.9.1.jar:na]
	at org.testcontainers.containers.DockerComposeContainer.startAmbassadorContainers(DockerComposeContainer.java:248) ~[testcontainers-1.9.1.jar:na]
	at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:158) ~[testcontainers-1.9.1.jar:na]
	at com.rieter.rds.util.DockerEnv.start(DockerUtil.kt:33) ~[classes/:na]
	at com.rieter.rds.util.DockerExtension.beforeAll(DockerUtil.kt:13) ~[classes/:na]
	at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$invokeBeforeAllCallbacks$7(ClassTestDescriptor.java:358) ~[junit-jupiter-engine-5.3.1.jar:5.3.1]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeBeforeAllCallbacks(ClassTestDescriptor.java:358) ~[junit-jupiter-engine-5.3.1.jar:5.3.1]
	at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.before(ClassTestDescriptor.java:197) ~[junit-jupiter-engine-5.3.1.jar:5.3.1]
	at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.before(ClassTestDescriptor.java:74) ~[junit-jupiter-engine-5.3.1.jar:5.3.1]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:102) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:95) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:71) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at java.util.ArrayList.forEach(ArrayList.java:1257) ~[na:1.8.0_192]
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:110) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:95) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:71) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) ~[junit-platform-engine-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74) ~[junit5-rt.jar:na]
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) ~[junit-rt.jar:na]
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) ~[junit-rt.jar:na]
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) ~[junit-rt.jar:na]

Can anybody help me? Thanks

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 31 (10 by maintainers)

Most upvoted comments

BTW thx for creating/maintaining testcontainers! Great stuff!

The problem which I posted yesterday got solved by cleaning up iptables rules, bridge network devices, and routing table entries created by docker containers. docker network prune --filter "until=24h"

But still I noticed that the image containers are not properly stopped if there are test failures. I’ve an application which has around 100~ integration tests. All uses testcontainer-postgresql and about 50 tests failed due to some other reasons. And I found that at the end docker ps command shows about 50 postgres:x.x.x containers are still running in my local system. This seems an error in testcontainer. Or this has to be manually handled in our tests postgresContainer.stop() ?

@bsideup thx for the quick response! I understand that its not ideal that DNS seems to be not perfect but this never stopped any other process from working correctly. I can run the docker-compose file on that machine manually without any issues. Just as soon as testcontainers&docker-compose is involed chances are around 80% that within a month it will develop sporadic issues. If you think it works for others I guess I have to take your word for it 😉