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

Address Compose containers by service name

Aperta
#1,540 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
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker-compose, typescript

Direzione di ricerca

Start by reading packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts and started-docker-compose-environment.ts, then trace the compose name parsing entry point in packages/testcontainers/src/docker-runtime/clients/compose/parse-compose-container-name.ts. Check how containers are identified and how wait strategies and getContainer resolve them; done means those APIs accept service names with an optional replica index while retaining container-name support, and the constructor parameter is named for the directory it receives.

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

Descrizione

enhancement minor

What happens

DockerComposeEnvironment identifies containers by container name, not by the service name written in the compose file:

const environment = await new DockerComposeEnvironment(dir, "docker-compose.yml")
  .withWaitStrategy("redis-1", Wait.forLogMessage("Ready to accept connections"))
  .up();

const redis = environment.getContainer("redis-1");
  • The -1 suffix is a Compose naming detail the user has to know.
  • A service with container_name: set is keyed by that name instead.
  • A wait strategy registered under the service name ("redis") matches nothing. up() now logs a warning for that case, and the docs carry a callout, but the default wait strategy is still what runs.
  • getContainer("redis") throws Cannot get container "redis" as it is not running.

The first constructor parameter is also misnamed: composeFilePath is the directory that contains the compose files, and the docs assign it "/path/to/build-context".

Expected

  • withWaitStrategy and getContainer accept a service name, with an optional replica index, and keep accepting a container name.
  • The constructor parameter is named for what it is.

Where

  • packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts
  • packages/testcontainers/src/docker-compose-environment/started-docker-compose-environment.ts
  • packages/testcontainers/src/container-runtime/clients/compose/parse-compose-container-name.ts

Notes

  • Java uses service names throughout: waitingFor(serviceName, strategy), getServiceHost(serviceName, port), getContainerByServiceName(serviceName), with an optional instance number on withExposedService. Go has ServiceContainer(ctx, svcName) and WaitForService(name, strategy).
  • Compose labels each container with com.docker.compose.service and com.docker.compose.container-number, so resolving a service does not need name parsing.
  • Related: #647.

Dependencies

  • Nothing blocks this. It can start now.
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.