Skip to content

"Listening ports" wait strategy does not work well on Podman, for images with multiple default exposed ports #1108

@richvdh

Description

@richvdh

Given an image which contains multiple EXPOSEd ports, such as this test image.

Attempt to start it, but only expose one port:

const container = await new GenericContainer("richvdh/testcontainer:1.0.2")
    .withExposedPorts(8080)
    .start();

Expected Behaviour

GenericContainer.start should complete and return.

Actual Behaviour

At least under Podman, GenericContainer.start waits for the timeout and then throws an error.

Testcontainer Logs

  testcontainers [DEBUG] Checking container runtime strategy "TestcontainersHostStrategy"... +0ms
  testcontainers [DEBUG] Loading ".testcontainers.properties" file... +0ms
  testcontainers [DEBUG] Loaded ".testcontainers.properties" file +2ms
  testcontainers [DEBUG] Found custom configuration: dockerHost: "unix:///run/user/1000/podman/podman.sock" +0ms
  testcontainers [DEBUG] Container runtime strategy "TestcontainersHostStrategy" is not applicable +0ms
  testcontainers [DEBUG] Checking container runtime strategy "ConfigurationStrategy"... +0ms
  testcontainers [TRACE] Fetching Docker info... +0ms
  testcontainers [TRACE] Fetching remote container runtime socket path... +371ms
  testcontainers [TRACE] Resolving host... +0ms
  testcontainers [TRACE] Fetching Compose info... +1ms
  testcontainers [TRACE] Looking up host IPs... +0ms
  testcontainers [TRACE] Initialising clients... +2ms
  testcontainers [TRACE] Container runtime info:
  testcontainers {
  testcontainers   "node": {
  testcontainers     "version": "v22.17.0",
  testcontainers     "architecture": "x64",
  testcontainers     "platform": "linux"
  testcontainers   },
  testcontainers   "containerRuntime": {
  testcontainers     "host": "localhost",
  testcontainers     "hostIps": [
  testcontainers       {
  testcontainers         "address": "::1",
  testcontainers         "family": 6
  testcontainers       },
  testcontainers       {
  testcontainers         "address": "127.0.0.1",
  testcontainers         "family": 4
  testcontainers       }
  testcontainers     ],
  testcontainers     "remoteSocketPath": "/run/user/1000/podman/podman.sock",
  testcontainers     "indexServerAddress": "https://index.docker.io/v1/",
  testcontainers     "serverVersion": "4.3.1",
  testcontainers     "operatingSystem": "debian",
  testcontainers     "operatingSystemType": "linux",
  testcontainers     "architecture": "amd64",
  testcontainers     "cpus": 16,
  testcontainers     "memory": 33247903744,
  testcontainers     "runtimes": [
  testcontainers       "crun",
  testcontainers       "kata",
  testcontainers       "krun",
  testcontainers       "runc",
  testcontainers       "runj",
  testcontainers       "runsc"
  testcontainers     ],
  testcontainers     "labels": []
  testcontainers   }
  testcontainers } +0ms
  testcontainers [DEBUG] Container runtime strategy "ConfigurationStrategy" works +0ms
  testcontainers [DEBUG] Checking if image exists "richvdh/testcontainer:1.0.2"... +0ms
  testcontainers [DEBUG] Checked if image exists "richvdh/testcontainer:1.0.2" +10ms
  testcontainers [DEBUG] Image "richvdh/testcontainer:1.0.2" already exists +0ms
  testcontainers [DEBUG] Acquiring lock file "/tmp/testcontainers-node.lock"... +2ms
  testcontainers [DEBUG] Acquired lock file "/tmp/testcontainers-node.lock" +2ms
  testcontainers [DEBUG] Listing containers... +0ms
  testcontainers [DEBUG] Listed containers +8ms
  testcontainers [DEBUG] Reusing existing Reaper for session "fc4d4da4e2e0"... +0ms
  testcontainers [DEBUG] [e7d6f54cf93e] Connecting to Reaper (attempt 1) on "localhost:45189"... +0ms
  testcontainers [DEBUG] [e7d6f54cf93e] Connected to Reaper +1ms
  testcontainers [DEBUG] Releasing lock file "/tmp/testcontainers-node.lock"... +0ms
  testcontainers [DEBUG] Released lock file "/tmp/testcontainers-node.lock" +1ms
  testcontainers [DEBUG] Creating container for image "richvdh/testcontainer:1.0.2"... +0ms
  testcontainers [DEBUG] [70103837631a] Created container for image "richvdh/testcontainer:1.0.2" +192ms
  testcontainers [INFO] [70103837631a] Starting container for image "richvdh/testcontainer:1.0.2"... +1ms
  testcontainers [DEBUG] [70103837631a] Starting container... +0ms
  testcontainers [DEBUG] [70103837631a] Started container +183ms
  testcontainers [INFO] [70103837631a] Started container for image "richvdh/testcontainer:1.0.2" +0ms
  testcontainers [ERROR] [70103837631a] Timed out after 10000ms while waiting for container ports to be bound to the host +10s
/home/rav/work/testcontainer/node_modules/testcontainers/build/generic-container/inspect-container-util-ports-exposed.js:15
        return new Error(message);
               ^

Error: Timed out after 10000ms while waiting for container ports to be bound to the host
    at /home/rav/work/testcontainer/node_modules/testcontainers/build/generic-container/inspect-container-util-ports-exposed.js:15:16
    at IntervalRetry.retryUntil (/home/rav/work/testcontainer/node_modules/testcontainers/build/common/retry.js:29:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async inspectContainerUntilPortsExposed (/home/rav/work/testcontainer/node_modules/testcontainers/build/generic-container/inspect-container-util-ports-exposed.js:6:20)
    at async GenericContainer.startContainer (/home/rav/work/testcontainer/node_modules/testcontainers/build/generic-container/generic-container.js:139:31)
    at async file:///home/rav/work/testcontainer/main.mjs:9:19

Steps to Reproduce

https://github.com/richvdh/testcontainer contains a demonstration.

  1. Clone the repo
  2. npm run start
  3. Observe that the command hangs, and then times out after 10 seconds.

Environment Information

  • Operating System: Debian bookworm
  • Docker Version: podman version 4.3.1
  • Node version: v22.17.0
  • Testcontainers version: 11.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageInvestigation required

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions