Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: No host port found for host IP #818

Open
theogravity opened this issue Aug 12, 2024 · 2 comments
Open

Error: No host port found for host IP #818

theogravity opened this issue Aug 12, 2024 · 2 comments
Labels
triage Investigation required

Comments

@theogravity
Copy link

theogravity commented Aug 12, 2024

Expected Behaviour
Container should start up.

Actual Behaviour


⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: No host port found for host IP
 ❯ resolveHostPortBinding ../../node_modules/.pnpm/testcontainers@10.11.0/node_modules/testcontainers/src/utils/bound-ports.ts:74:9
 ❯ ../../node_modules/.pnpm/testcontainers@10.11.0/node_modules/testcontainers/src/utils/bound-ports.ts:55:46
 ❯ Function.fromInspectResult ../../node_modules/.pnpm/testcontainers@10.11.0/node_modules/testcontainers/src/utils/bound-ports.ts:54:41
 ❯ GenericContainer.startContainer ../../node_modules/.pnpm/testcontainers@10.11.0/node_modules/testcontainers/src/generic-container/generic-container.ts:177:35
 ❯ processTicksAndRejections node:internal/process/task_queues:95:5
 ❯ createNewReaper ../../node_modules/.pnpm/testcontainers@10.11.0/node_modules/testcontainers/src/reaper/reaper.ts:84:28
 ❯ ../../node_modules/.pnpm/testcontainers@10.11.0/node_modules/testcontainers/src/reaper/reaper.ts:38:14
 ❯ withFileLock ../../node_modules/.pnpm/testcontainers@10.11.0/node_modules/testcontainers/src/common/file-lock.ts:14:12
 ❯ getReaper ../../node_modules/.pnpm/testcontainers@10.11.0/node_modules/testcontainers/src/reaper/reaper.ts:29:12

Testcontainer Logs

  testcontainers [TRACE] Container runtime info:
  testcontainers {
  testcontainers   "node": {
  testcontainers     "version": "v20.16.0",
  testcontainers     "architecture": "arm64",
  testcontainers     "platform": "darwin"
  testcontainers   },
  testcontainers   "containerRuntime": {
  testcontainers     "host": "localhost",
  testcontainers     "hostIps": [
  testcontainers       {
  testcontainers         "address": "::1",
  testcontainers         "family": 6
  testcontainers       }
  testcontainers     ],
  testcontainers     "remoteSocketPath": "/var/run/docker.sock",
  testcontainers     "indexServerAddress": "https://index.docker.io/v1/",
  testcontainers     "serverVersion": "27.1.1",
  testcontainers     "operatingSystem": "Docker Desktop",
  testcontainers     "operatingSystemType": "linux",
  testcontainers     "architecture": "aarch64",
  testcontainers     "cpus": 12,
  testcontainers     "memory": 8219254784,
  testcontainers     "runtimes": [
  testcontainers       "io.containerd.runc.v2",
  testcontainers       "runc"
  testcontainers     ]
  testcontainers   },
  testcontainers   "compose": {
  testcontainers     "version": "2.29.1-desktop.1",
  testcontainers     "compatability": "v2"
  testcontainers   }
  testcontainers }

Steps to Reproduce

  const postgresContainer = await new PostgreSqlContainer().start();

  process.env.DB_PORT = postgresContainer.getPort().toString();
  process.env.DB_USER = postgresContainer.getUsername();
  process.env.DB_PASS = postgresContainer.getPassword();
  process.env.DB_NAME = postgresContainer.getDatabase();

Environment Information

  • Operating System: MacOS 14.5
  • Docker Version: 4.33.0 (160616)
  • Node version: 20.16.0
  • Testcontainers version: "@testcontainers/postgresql": "10.11.0"

This is a co-worker's environment. I've checked their MacOS network settings - nothing seems out of the ordinary. They have an IPv4 setup with IPv6 set to automatic (my own working environment is more extensive, with custom IPv6). Their docker configuration settings are the default for a docker desktop installation. We also tried stopping all existing containers before re-running without any luck.

One thing I noticed between my own working environment and theirs, is the following:

  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     ],

Mine has an IPv4 recognized while theirs do not:

  testcontainers   "containerRuntime": {
  testcontainers     "host": "localhost",
  testcontainers     "hostIps": [
  testcontainers       {
  testcontainers         "address": "::1",
  testcontainers         "family": 6
  testcontainers       }
  testcontainers     ],
@theogravity
Copy link
Author

We found a workaround:

TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1

@kiview
Copy link
Member

kiview commented Aug 13, 2024

Testcontainers for Node should support IPv6 port mappings since a long time.

Interestingly, we just closed this IPv6 related PR in tc-go yesterday (testcontainers/testcontainers-go#2403), because Docker/Moby now supports consistent IPv4/IPv6 port mappings (since Docker 27, see moby/moby#47871).

Do you have an idea what is happening here @cristianrgreco? Given the upstream change in Moby, does it maybe make sense to remove the conditional IPv4/IPv6 logic from tc-node, to simplify the code?

@cristianrgreco cristianrgreco added the triage Investigation required label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Investigation required
Projects
None yet
Development

No branches or pull requests

3 participants