Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
If Startables.deepStart is not used (i.e. instead of calling startGlobalContainersParallel() we call startGlobalContainersSequentially()), then all work fine.
Removing withCreateContainerCmdModifier also helps.
I tried to add withCreateContainerCmdModifier to other containers (e.g. MySQLContainer) and it hungs too, so this bug doesn't depend on the container.
Relevant log output
19:12:53.402 [testcontainers-lifecycle-0] INFO tc.testcontainers/ryuk:0.7.0 -- Container testcontainers/ryuk:0.7.0 started in PT0.7214507S
19:12:53.406 [testcontainers-ryuk] DEBUG org.testcontainers.utility.ResourceReaper -- Sending 'label=org.testcontainers%3Dtrue&label=org.testcontainers.lang%3Djava&label=org.testcontainers.version%3D1.19.8&label=org.testcontainers.sessionId%3D2300acd2-8cc9-41ef-b3e1-37ea382ee1a8' to Ryuk
19:12:53.406 [testcontainers-ryuk] DEBUG org.testcontainers.utility.RyukResourceReaper -- Received 'ACK' from Ryuk
19:12:53.406 [testcontainers-lifecycle-0] INFO org.testcontainers.utility.RyukResourceReaper -- Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
19:12:53.407 [testcontainers-lifecycle-0] DEBUG org.testcontainers.DockerClientFactory -- Checks are enabled
19:12:53.407 [testcontainers-lifecycle-0] INFO org.testcontainers.DockerClientFactory -- Checking the system...
19:12:53.407 [testcontainers-lifecycle-0] INFO org.testcontainers.DockerClientFactory -- ✔︎ Docker server version should be at least 1.6.0
19:12:53.407 [testcontainers-lifecycle-0] DEBUG org.testcontainers.utility.PrefixingImageNameSubstitutor -- No prefix is configured
19:12:53.407 [testcontainers-lifecycle-0] DEBUG org.testcontainers.utility.ImageNameSubstitutor -- Did not find a substitute image for fsouza/fake-gcs-server:1 (using image substitutor: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor'))
19:12:53.407 [testcontainers-lifecycle-0] DEBUG org.testcontainers.images.AbstractImagePullPolicy -- Using locally available and not pulling image: fsouza/fake-gcs-server:1
19:12:53.407 [testcontainers-lifecycle-0] DEBUG tc.fsouza/fake-gcs-server:1 -- Starting container: fsouza/fake-gcs-server:1
19:12:53.407 [testcontainers-lifecycle-0] DEBUG tc.fsouza/fake-gcs-server:1 -- Trying to start container: fsouza/fake-gcs-server:1 (attempt 1/1)
19:12:53.407 [testcontainers-lifecycle-0] DEBUG tc.fsouza/fake-gcs-server:1 -- Starting container: fsouza/fake-gcs-server:1
19:12:53.407 [testcontainers-lifecycle-0] INFO tc.fsouza/fake-gcs-server:1 -- Creating container for image: fsouza/fake-gcs-server:1
19:12:53.407 [testcontainers-lifecycle-0] DEBUG org.testcontainers.utility.RegistryAuthLocator -- Looking up auth config for image: fsouza/fake-gcs-server:1 at registry: https://index.docker.io/v1/
19:12:53.408 [testcontainers-lifecycle-0] DEBUG org.testcontainers.utility.RegistryAuthLocator -- No matching Auth Configs - falling back to defaultAuthConfig [null]
19:12:53.408 [testcontainers-lifecycle-0] DEBUG org.testcontainers.dockerclient.AuthDelegatingDockerClientConfig -- Effective auth config [null]
Module
Core
Testcontainers version
1.19.8
Using the latest Testcontainers version?
Yes
Host OS
Windows 11
Host Arch
x86
Docker version
What happened?
Startables.deepStart(container).join();
hungs indefinitely whencontainer
haswithCreateContainerCmdModifier
defined.Example:
If
Startables.deepStart
is not used (i.e. instead of callingstartGlobalContainersParallel()
we callstartGlobalContainersSequentially()
), then all work fine.Removing
withCreateContainerCmdModifier
also helps.I tried to add
withCreateContainerCmdModifier
to other containers (e.g.MySQLContainer
) and it hungs too, so this bug doesn't depend on the container.Relevant log output
Additional Information
Minimal reproduce: tc-parallel-start-bug.zip.
Docs aboutt parallel container startup: https://java.testcontainers.org/features/advanced_options/#parallel-container-startup