Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Expose host ports per container instead of globally

Aperta
#1,557 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
54/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
docker, node.js, typescript
Ambito
backend, testing

Direzione di ricerca

Read start and startContainer in packages/testcontainers/src/generic-container/generic-container.ts, then trace host access through packages/testcontainers/src/port-forwarder/port-forwarder.ts and packages/testcontainers/src/test-containers.ts. Check how the request affects reuse hashing and coordinate with #1520 and #1522. Done means a container can opt in with withExposedHostPorts(...ports), unrequested containers stay unaffected, and the existing global call continues to work.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement minor

What happens

TestContainers.exposeHostPorts(...ports) is global and permanent. Once it has been called, every container started afterwards in the process:

  • is connected to the port forwarder's network, in addition to its own
  • gets a host.testcontainers.internal entry in its extra hosts

whether or not it needs to reach the host. A container cannot opt out, and exposure cannot be scoped to one test. The extra network shows up in getNetworkNames().

Expected

Host access is requested per container, for example withExposedHostPorts(...ports). Containers that did not ask are left alone. The global call keeps working.

Where

  • start and startContainer in packages/testcontainers/src/generic-container/generic-container.ts
  • packages/testcontainers/src/port-forwarder/port-forwarder.ts
  • packages/testcontainers/src/test-containers.ts

Notes

  • Java keeps the global Testcontainers.exposeHostPorts(...) and makes containers opt in with withAccessToHost(true). Go's WithHostPortAccess(ports...) is per container.
  • Related: #1188.
  • Changing the global call so that containers no longer get host access by default would be major. Adding the per-container form is minor.

Dependencies

  • Stack on #1520: the host-access wiring is in start(), where it is one of the things that accumulates.
  • Coordinate with #1522: host access changes the create request, so it affects the reuse hash.
Lingua principale
TypeScript
Stelle
2.6k
Fork
274
Merge medio
1g 14h
PR unite (30g)
44

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di testcontainers/testcontainers-node

Tutte le issue di testcontainers/testcontainers-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.