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

Bug: HealthcheckWaitStrategy returns error with DockerCompose

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

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
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
docker-compose, python
Lĩnh vực
devops, testing-qa

Hướng nghiên cứu

Đọc testcontainers/compose/compose.py quanh start và testcontainers/core/wait_strategies.py quanh HealthcheckWaitStrategy.wait_until_ready. Tái hiện ví dụ Docker Compose được cung cấp và kiểm tra các test của wait-strategy hiện có. Hoàn tất khi việc chờ healthcheck của DockerCompose không còn truy cập vào một thuộc tính ComposeContainer không được hỗ trợ và regression test chạy thành công.

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

Mô tả

Describe the bug

When applying a 'waiting_for' to a DockerCompose object with a HealthcheckWaitStrategy, it returns an AttributeError: “ComposeContainer” object has no attribute “attrs”.

To Reproduce

import os
from testcontainers.compose import DockerCompose
from testcontainers.core.wait_strategies import HealthcheckWaitStrategy

BASE_DIR = os.path.dirname(__file__)

compose = DockerCompose(context=BASE_DIR, compose_file_name = "docker-compose.yml")
compose.waiting_for({"web": HealthcheckWaitStrategy().with_startup_timeout(60)})
compose.start()

docker-compose.yml:

version: '3.8'
services:
  web:
    image: nginx
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

Traceback:

Traceback (most recent call last):
  File "<path>/test.py", line 9, in <module>
    compose.start()
  File "testcontainers/compose/compose.py", line 303, in start
    strategy.wait_until_ready(container)
  File "testcontainers/core/wait_strategies.py", line 487, in wait_until_ready
    health = wrapped.attrs.get("State", {}).get("Health", {})
             ^^^^^^^^^^^^^
AttributeError: 'ComposeContainer' object has no attribute 'attrs'

Runtime environment

$ uname -a
Linux kali 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 3.12.1
$ poetry show | grep testcontainers
testcontainers                                  4.13.2 
Ngôn ngữ chính
Python
Star
2.3k
Fork
386
Merge trung bình
4 giờ 40 phút
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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

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

Issue tương tự

Thêm issue về Python

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.