-
Notifications
You must be signed in to change notification settings - Fork 341
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels