Skip to content

Make container port mapping timeout configurable - #11952

Closed
khalilswdp wants to merge 1 commit into
testcontainers:mainfrom
khalilswdp:configurable-port-mapping-timeout
Closed

Make container port mapping timeout configurable#11952
khalilswdp wants to merge 1 commit into
testcontainers:mainfrom
khalilswdp:configurable-port-mapping-timeout

Conversation

@khalilswdp

Copy link
Copy Markdown

During container startup, GenericContainer polls inspectContainer until the Docker
daemon reports all exposed ports as mapped, with a hard-coded 5-second limit. On heavily
loaded hosts (shared CI runners in particular) the daemon can take longer, and the
resulting failure is an opaque Awaitility timeout rather than the detailed diagnostics
produced for later startup failures.

Changes

  • Add a container.port.mapping.timeout configuration property (default: 5 seconds, so
    out-of-the-box behavior is unchanged), read via the standard mechanism — env var
    TESTCONTAINERS_CONTAINER_PORT_MAPPING_TIMEOUT, ~/.testcontainers.properties, or a
    classpath testcontainers.properties.
  • Use it in GenericContainer.tryStart() in place of the hard-coded value.
  • Document the property in docs/features/configuration.md and cover the
    default/property/env-var precedence in TestcontainersConfigurationTest.

A configuration property (rather than a per-container API) was chosen deliberately: the
latency this timeout absorbs is a characteristic of the Docker daemon and host load, not
of any particular container, mirroring existing environment-level knobs such as
client.ping.timeout.

@khalilswdp
khalilswdp requested a review from a team as a code owner July 28, 2026 20:01
@eddumelendez

Copy link
Copy Markdown
Member

Closing. See #11938 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants