testcontainers / testcontainers-java

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.
https://testcontainers.org
MIT License
7.97k stars 1.64k forks source link

Timed out waiting for container port to open #4125

Open jvmlet opened 3 years ago

jvmlet commented 3 years ago

3923 is still reproducible with com.playtika.testcontainers:embedded-keycloak:2.0.8 even after forcibly upgrade org.testcontainers:testcontainers transitive dependency to 1.15.3, getting

Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [49187] should be listening)
    at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:49)
    at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
    at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:892)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:440)
    ... 104 more

Docker For Windows 3.3.3

jvmlet commented 3 years ago

Had to downgrade to Docker Desktop 2.4.0.0 with engine version19.03.13 to make it work. Looks like 20.x is the cause

mattca commented 3 years ago

Also seeing this exact issue with testcontainers version 1.15.3 and Docker Desktop for Mac, version 3.3.3. Also believe docker engine 20.x to be the cause. Our tests pass on Jenkins build with the older 19.03.11 docker engine.

jvmlet commented 3 years ago

After upgrading to the latest Docker Desktop 3.4.0 (with Docker Engine 20.10.7 that contains this fix ) and explicitly setting embedded keycloak db vendor to h2 as advised here, I don't experience this issue anymore. Not sure which one of above changes solved the issue though...

schowdiah commented 2 years ago

How do you "close" this issue, it keeps happening with random versions of Docker engine and docker desktop.

bsideup commented 2 years ago

@schowdiah since the issue is caused by Docker for Windows and not Testcontainers, consider reporting it to the Docker team. We do our best on the Testcontainers side to make things work but some issues (usually related to Docker) are out of our control, unfortunately.

memekas commented 2 years ago
import org.testcontainers.containers.GenericContainer
import org.testcontainers.utility.DockerImageName

open class KGenericContainer(image: String) : GenericContainer<KGenericContainer>(DockerImageName.parse(image))

fun main() {
    val container = KGenericContainer("MY_CONTAINER")
        .withExposedPorts(8081)
    container.start()
}
org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [62362] should be listening)
    at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:49)
    at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
    at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:923)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:466)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:329)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:327)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:315)

macbook m1 chip macOS 11.6 docker desktop 4.1.1 docker engine 20.10.8 testcontainers 1.16.0

DJ-Glock commented 2 years ago

Yeah. Facing the same issue on RHE. :( Tried Docker 20.10.8 - the same.

org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (servername ports: [49162] should be listening)
    at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:49)
    at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35)
    at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:923)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:466)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:329)
kiview commented 2 years ago

@DJ-Glock can you please try out if it works with the basic example from our reproducer? https://github.com/testcontainers/testcontainers-java-repro

Also, please follow up in issue #4602, this issue has been closed by the original author and had a different cause.

DJ-Glock commented 2 years ago

@kiview thanks for the response. I spent some time reading issues details and will start with trying 1.16.2 version. Then I'll try to reproduce it with basic example and update an issue #4602 with details.

anandrathnauni commented 1 year ago

Noticed this issue happens only if we do .withExposedPorts(9090)

kacirekj commented 1 year ago

Same issue here. I love this java libraries.

` @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest( classes = {Application.class, TransactionRepository.class, TransactionService.class, TransactionMapper.class, TransactionRest.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT ) @ActiveProfiles("test") class TransactionRestITest {

static GenericContainer<?> postgres = new GenericContainer<>(DockerImageName.parse("postgres:10.16"))
        .withExposedPorts(61030)
        .withEnv("POSTGRES_PASSWORD", "password");

@DynamicPropertySource
static void properties(DynamicPropertyRegistry registry) {
    postgres.start();
    System.out.println("");
}

`

` Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [59390] should be listening)

`

SaverioMirko commented 1 year ago

Hi there,

did you find any fix to this issue? I do not understand how to solve this problem. Thanks

bakarJc commented 12 months ago

I am also still facing this error running,

@Container static GenericContainer<?> eventStoreContainer = new GenericContainer("eventstore/eventstore:release-4.1.3").withExposedPorts(1113, 2113);

I have a feeling it might be a Mac specific issue as my teammates don't get this running the same test on Intel machines running Ubuntu. I tried connecting to a remote Docker engine running on an Ubuntu EC2 instance but still get the "timed out waiting for container ports to open"

I've also confirmed by running docker ps that the container listens on 1112-1113/tcp, 2112-2113/tcp

jvmlet commented 12 months ago

I'll reopen it since many folks are complaining

prizrakbeckman commented 11 months ago

I still have this issue with TestContainers. I am using windows with Docker 24, testcontainers 1.18 version, with cucumber hooks.

var container= new GenericContainer(DockerImageName.parse("wiremock/wiremock"))
            .withExposedPorts(MECI_WIREMOCK_INTERNAL_PORT)
            .withClasspathResourceMapping("wiremock/modules/custom-service", "/home/wiremock", BindMode.READ_ONLY);
        container.start();
        logger.info("Meci server started");
        TestContext.CONTEXT.set(TestConstants.MECI_MOCK_SERVER, meci);

I have this exception when running :

org.testcontainers.containers.ContainerLaunchException: Container startup failed for image wiremock/wiremock:latest
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:349)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
    at net.haulogy.hauerp.esb.steps.CucumberHooks.prepareMeciMockServer2(CucumberHooks.java:71)
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
    at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
    at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
    at net.haulogy.hauerp.esb.steps.CucumberHooks.prepareMeciMockServer2(CucumberHooks.java:71)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at io.cucumber.java.Invoker.doInvoke(Invoker.java:66)
    at io.cucumber.java.Invoker.invokeStatic(Invoker.java:80)
    at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:45)
    at io.cucumber.java.JavaStaticHookDefinition.execute(JavaStaticHookDefinition.java:49)
    at io.cucumber.core.runner.Runner.executeHook(Runner.java:112)
    at io.cucumber.core.runner.Runner.lambda$executeHooks$2(Runner.java:99)
    at io.cucumber.core.runner.ThrowableCollector.execute(ThrowableCollector.java:21)
    at io.cucumber.core.runner.Runner.executeHooks(Runner.java:99)
    at io.cucumber.core.runner.Runner.runBeforeAllHooks(Runner.java:89)
    at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
    at io.cucumber.core.runtime.CucumberExecutionContext.runBeforeAllHooks(CucumberExecutionContext.java:94)
    at io.cucumber.junit.platform.engine.CucumberEngineExecutionContext.runBeforeAllHooks(CucumberEngineExecutionContext.java:101)
    at io.cucumber.junit.platform.engine.CucumberEngineDescriptor.ifChildren(CucumberEngineDescriptor.java:51)
    at io.cucumber.junit.platform.engine.CucumberEngineDescriptor.before(CucumberEngineDescriptor.java:26)
    at io.cucumber.junit.platform.engine.CucumberEngineDescriptor.before(CucumberEngineDescriptor.java:11)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:148)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:73)
    at org.junit.platform.suite.engine.SuiteLauncher.execute(SuiteLauncher.java:63)
    at org.junit.platform.suite.engine.SuiteTestDescriptor.execute(SuiteTestDescriptor.java:128)
    at org.junit.platform.suite.engine.SuiteTestEngine.lambda$execute$0(SuiteTestEngine.java:73)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
    at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at org.junit.platform.suite.engine.SuiteTestEngine.execute(SuiteTestEngine.java:73)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at com.sun.proxy.$Proxy5.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:553)
    at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
    at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
    ... 83 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [60660] should be listening)
    at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:101)
    at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
    at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:964)
    at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:490)
    ... 85 more
andylamax commented 11 months ago

2023 and still experiencing this same problem with

Client: Docker Engine - Community
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:32:16 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:32:16 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.24
  GitCommit:        61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
 runc:
  Version:          1.1.9
  GitCommit:        v1.1.9-0-gccaecfc
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
emanuelvictor commented 11 months ago

That's worked for me.

@SpringBootTest
@Sql("/datasets/truncate_all_tables.sql")
public abstract class AbstractIntegrationTests {

    public AbstractIntegrationTests() {
        final GenericContainer<?> postgres = new GenericContainer<>(DockerImageName.parse("postgres:13.2-alpine"))
                .withEnv("POSTGRES_USER", "accessmanager")
                .withEnv("POSTGRES_PASSWORD", "accessmanager")
                .withEnv("POSTGRES_DB", "accessmanager");
        postgres.setPortBindings(Collections.singletonList(String.format("%d:%d/%s", 5433, 5432, InternetProtocol.TCP.toDockerNotation())));
        try {
            postgres.start();
        } catch (final Exception ignore) {
        }
    }
}

public class GroupPermissionRepositoryTests extends AbstractIntegrationTests {

    @Autowired
    private GroupRepository groupRepository;
    @Autowired
    private PermissionRepository permissionRepository;
    @Autowired
    private GroupPermissionRepository groupPermissionRepository;

    private final Group group = new Group();
    private Permission rootPermission;

    @BeforeEach
    void setUp() {
        group.setName("Access Group Name");
        groupRepository.save(group);
        rootPermission = permissionRepository.findById(1L).orElseThrow();
    }

    @Test
    public void mustListGroupsPermissionsByGroupId() {
        System.out.println(" ------ ");
        final GroupPermission groupPermission = new GroupPermission();
        groupPermission.setPermission(rootPermission);
        groupPermission.setGroup(group);
        groupPermissionRepository.save(groupPermission);

        final List<GroupPermission> groupsPermissionsSaved = groupPermissionRepository.listByGroupId(group.getId());

        System.out.println(groupsPermissionsSaved.size());
    }

}
idontusenumbers commented 9 months ago

I'm getting this with docker running in an ubuntu container running on docker under ubuntu.

This is happening in a test I'm running under gradle. I enabled debug logging and see this:

4349 DEBUG HostPortWaitStrategy           - External port check passed for [5432] mapped as [49178] in PT1.539845616S 
62809 DEBUG InternalHttpClient             - ep-00000011: cancel 
62810 DEBUG DefaultManagedHttpClientConnection - http-outgoing-1: close connection IMMEDIATE 
62810 DEBUG wire                           - http-outgoing-1 << "[read] I/O error: null" 
62810 DEBUG InternalHttpClient             - ep-00000011: endpoint closed 
62810 DEBUG InternalHttpClient             - ep-00000011: discarding endpoint 
62810 DEBUG PoolingHttpClientConnectionManager - ep-00000011: releasing endpoint 
62810 DEBUG PoolingHttpClientConnectionManager - ep-00000011: connection is not kept alive 
62810 DEBUG PoolingHttpClientConnectionManager - ep-00000011: connection released [route: {}->unix://localhost:2375][total available: 1; route allocated: 1 of 2147483647; total allocated: 1 of 2147483647] 
62810 DEBUG postgres:alpine                - Wait strategy threw an exception org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1 ports: [49178] should be listening)
        at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:112)
        at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)

This is especially weird because it says it passed, listing the port, then that it timed out, listing the same port! I've looked at the code of HostPortWaitStrategy and don't see an obvious way this could occur.

While the wait is going, I'm able to connect using netcat to the given port from within the same container gradle is running in.

idontusenumbers commented 9 months ago

I did some more testing. I added the causal exception to the log statement, seems the internal port check future gets canceled for some reason. I created my own HostPortWaitStrategy that omits the internal port check, and that got most of my containers to start and function as expected. But...

I'm still stuck trying to get a container based on ImageFromDockerfile to start. It seems to get stuck building (docker reports a container running with one of the build steps):

1714 INFO  DockerClientProviderStrategy   - Found Docker environment with local Unix socket (unix:///var/run/docker.sock) 
     TeamCityLogTest    1744 INFO  DockerClientFactory            - Docker host IP address is 172.17.0.1 
     TeamCityLogTest    1759 INFO  DockerClientFactory            - Connected to docker: 
      Server Version: 24.0.7
      API Version: 1.43
      Operating System: Ubuntu 20.04.6 LTS
      Total Memory: 31961 MB 
1784 INFO  1                              - Creating container for image: testcontainers/ryuk:0.5.1 
1789 INFO  RegistryAuthLocator            - Failure when attempting to lookup auth config. Please ignore if you don't have images in an authenticated registry. Details: (dockerImageName: testcontainers/ryuk:0.5.1, configFile: /root/.docker/config.json, configEnv: DOCKER_AUTH_CONFIG). Falling back to docker-java default behaviour. Exception message: Status 404: No config supplied. Checked in order: /root/.docker/config.json (file not found), DOCKER_AUTH_CONFIG (not set) 
1967 INFO  1                              - Container testcontainers/ryuk:0.5.1 is starting: 9548381043a9e20b2993664a7c0ebe213dc998ff42e2bf18b952eaea5ea1fddb 
2365 INFO  1                              - Container testcontainers/ryuk:0.5.1 started in PT0.58079803S 
2369 INFO  RyukResourceReaper             - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit 
2370 INFO  DockerClientFactory            - Checking the system... 
2370 INFO  DockerClientFactory            - ✔︎ Docker server version should be at least 1.6.0 
2402 INFO  ImageFromDockerfile            - Pre-emptively checking local images for 'alpine:latest', referenced via a Dockerfile. If not available, it will be pulled.
2407 INFO  ImageFromDockerfile            - Transferred 0 bytes to Docker daemon 

Then hangs.

I tried using the DockerFIleBuilder and withDockerfile(Path), both fail at the same spot. I'm able to build the file on the command line using the same docker file. After building, testcontainers gets past the container start method but then hangs on container.execInContainer.

I'm using testcontainers 1.19.3 and openjdk 17.0.9, running in Docker 24.0.7 running in ubuntu 20.04.6 container (build agent), running on docker 20.10.17 ubuntu 22.04.3 (host).

It previously worked fine, but I don't remember what I changed to break it.

This all works just fine on my M1 mac Temurin/openjdk 17.0.9, docker 24.0.6.

idontusenumbers commented 9 months ago

Further debugging: I created a simple app to test with and tested in the build agent this keeps failing in (continued to fail), and then a plain docker-in-docker image published by docker, and it succeeded. I then tried creating a fresh clone of the agent container and it worked. Pulling my hair out, I service docker restart and everything is working again. I had recreated that container multiple times up until that point and it never worked, I still have no idea what was causing the issue.

garrett-free commented 6 months ago

Seeing this problem as well

Docker version 20.10.22, build 3a2c30b63a Machine is a 2019 Mac Intel i9 with Java 11 application. TestContainers version: 1.17.4

Nothing changed in our integration test code and it just stopped working.

Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [49161] should be listening) at app//org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:102) at app//org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52) at app//org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:953) at app//org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:485)

joeldbit commented 1 month ago

Running into the same problem. Did anyone else on here find a workaround for this ?

Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [32802] should be listening) at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:112) at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52) at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:909) at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:500) ... 34 more

I'm using Rancher Desktop version: 1.12.1 Running on a Mac with an M2 Pro chip, on Sonoma 14.5 testcontainers version: 1.20.1 Docker Version:


Client:
 Version:           24.0.7-rd
 API version:       1.42 (downgraded from 1.43)
 Go version:        go1.20.10
 Git commit:        72ffacf
 Built:             Wed Nov  1 18:41:50 2023
 OS/Arch:           darwin/arm64
 Context:           default

Server:
 Engine:
  Version:          23.0.6
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.20.11
  Git commit:       9dbdbd4b6d7681bd18c897a6ba0376073c2a72ff
  Built:            Fri Nov 17 20:59:57 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          v1.7.2
  GitCommit:        0cae528dd6cb557f7201036e9f43420650207b58
 runc:
  Version:          1.1.7
  GitCommit:        860f061b76bb4fc671f0f9e900f7d80ff93d4eb7
 docker-init:
  Version:          0.19.0
  GitCommit: