Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#1,545 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
76/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, typescript
Lĩnh vực
backend, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
2.6k
Fork
274
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
44

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của testcontainers/testcontainers-node

Tất cả issue của testcontainers/testcontainers-node

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.