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

Address Compose containers by service name

Đang mở
#1,540 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/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-compose, typescript
Lĩnh vực
devtools, testing-qa

Hướng nghiên cứu

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.

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

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.
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.