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

Add `inspect()` and state accessors to started containers

Aperta
#1,545 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
76/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, typescript
Ambito
backend, testing

Direzione di ricerca

Read the listed StartedTestContainer and StartedGenericContainer files, then trace how InspectResult is received by the start hooks and mapped in map-inspect-result.ts. Check types.ts for the result shape and inspect existing tests around container state. Done when started containers expose a fresh inspect result and the requested state accessors, with exit code represented in InspectResult.

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

Descrizione

enhancement minor

What happens

A started container exposes its id, name, labels, hostname and network details, all captured when it started. It has no way to ask about its current state:

  • Is it still running?
  • What was the exit code?
  • What is the health status?
  • What does a fresh inspect say?

InspectResult is an exported type, but only the containerStarting/containerStarted hooks ever receive one. Everyone else has to go through the runtime client and Dockerode:

const client = await getContainerRuntimeClient();
const info = await client.container.inspect(client.container.getById(container.getId()));

That returns Dockerode's ContainerInspectInfo, not the library's InspectResult.

Expected

On StartedTestContainer:

  • inspect(): Promise<InspectResult> for a fresh result
  • convenience accessors built on it, for example isRunning() and getExitCode()

InspectResult gains what those need (exit code).

Where

  • packages/testcontainers/src/test-container.ts
  • packages/testcontainers/src/generic-container/started-generic-container.ts
  • packages/testcontainers/src/utils/map-inspect-result.ts
  • packages/testcontainers/src/types.ts

Notes

  • Java has isRunning(), isHealthy(), getContainerInfo() and getCurrentContainerInfo(). Go has Inspect(ctx), State(ctx) and IsRunning().
  • Useful for one-shot containers (wait for exit, read the exit code) and for assertions in tests that deliberately kill a container.

Dependencies

  • Nothing blocks this. It can start now.
  • Changes StartedTestContainer, which today means the interface, StartedGenericContainer and the forwarder on AbstractStartedContainer. Several other issues do the same. The edits do not overlap, so they can go in parallel.
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.