Skip to content

Commit 1fadb40

Browse files
ticapixalexanderankinTranquility2
authored
fix(core): add container logs to TimeoutError when wait strategy times out (#1007)
Include container logs in TimeoutError when wait strategy times out Improves debugging when a container fails to start properly by attaching the stdout/stderr logs directly to the raised TimeoutError. --------- Co-authored-by: Dave Ankin <alexanderankin@gmail.com> Co-authored-by: Roy Moore <roy@moore.co.il>
1 parent 4c53b89 commit 1fadb40

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

core/testcontainers/core/container.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ def start(self) -> Self:
221221
docker_client.start(self._container)
222222

223223
if self._wait_strategy is not None:
224-
self._wait_strategy.wait_until_ready(self)
224+
try:
225+
self._wait_strategy.wait_until_ready(self)
226+
except TimeoutError as ex:
227+
if hasattr(ex, "add_note"):
228+
ex.add_note(self._container.logs().decode())
229+
raise ex
225230

226231
logger.info("Container started: %s", self._container.short_id)
227232

0 commit comments

Comments
 (0)