testcontainers / testcontainers/testcontainers-java

Stop waiting for port when container exited

Open
#2,225 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

resolution/acknowledged
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

try (GenericContainer<?> genericContainer = new GenericContainer<>("alpine:3.7")) {
    genericContainer
            .withCommand("false") // exit quickly
            .withExposedPorts(1234)
            .waitingFor(Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(1000)))
            .start(); // should fail quickly
}
Observed

Waiting for exposed port takes 1000s

Expected

Stop waiting for port, since container is exited.

$ docker ps -a
CONTAINER ID        IMAGE                               COMMAND             CREATED              STATUS                          PORTS                     NAMES
a8eb2b690815        alpine:3.7                          "false"             About a minute ago   Exited (1) About a minute ago                             gifted_northcutt
e9ce5b30960c        quay.io/testcontainers/ryuk:0.2.3   "/app"              About a minute ago   Up About a minute               0.0.0.0:33383->8080/tcp   testcontainers-ryuk-7cf21936-f4ce-49ac-9ab8-6d278dcb07c0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GenericContainer.start and the Wait.forListeningPort startup-wait path, then reproduce the Alpine example with the false command and exposed port. Done means startup stops waiting and fails promptly when Docker reports that the container has exited, rather than waiting for the full timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.