testcontainers / testcontainers/testcontainers-python

Bug: HealthcheckWaitStrategy returns error with DockerCompose

Open
#905 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.3k
Forks
386
Avg merge
4h 40m
Merged PRs (30d)
1

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 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read testcontainers/compose/compose.py around start and testcontainers/core/wait_strategies.py around HealthcheckWaitStrategy.wait_until_ready. Reproduce the supplied Docker Compose example and inspect existing wait-strategy tests. Done when DockerCompose healthcheck waiting no longer accesses an unsupported ComposeContainer attribute and the regression test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker-compose, python
Domain
devops, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.