Skip to content

Issue with testing ryuk under dind #983

@Tranquility2

Description

@Tranquility2

We seem to have an issue that is not easy to reproduce with ryuk under dind.
the issue started to appear after I upgraded to Docker 29.3.0

 Engine:
  Version:          29.3.0
  API version:      1.54 (minimum version 1.40)
  Go version:       go1.25.7
  Git commit:       83bca51
  Built:            Thu Mar  5 14:25:48 2026
  OS/Arch:          linux/amd64
  Experimental:     false

Example from the tests:

=================================== FAILURES ===================================
_____________________________ test_wait_for_reaper _____________________________
core/tests/test_ryuk.py:46: in test_wait_for_reaper
    with pytest.raises(NotFound):
E   Failed: DID NOT RAISE <class 'docker.errors.NotFound'>
------------------------------ Captured log call -------------------------------
INFO     testcontainers.core.container:container.py:178 Pulling image testcontainers/ryuk:0.8.1
INFO     testcontainers.core.container:container.py:207 Container started: 11c29242a3a6
INFO     testcontainers.core.container:container.py:178 Pulling image hello-world
INFO     testcontainers.core.container:container.py:207 Container started: 0faee54fa35a
_________________________ test_container_without_ryuk __________________________
.venv/lib/python3.10/site-packages/docker/api/client.py:275: in _raise_for_status
    response.raise_for_status()
.venv/lib/python3.10/site-packages/requests/models.py:1026: in raise_for_status
    raise HTTPError(http_error_msg, response=self)
E   requests.exceptions.HTTPError: 409 Client Error: Conflict for url: http+docker://localhost/v1.54/containers/11c29242a3a66f2fc35fe87d8ccdf169c05af8b3a946bb823b7aa295b9bde314?v=True&link=False&force=True

The above exception was the direct cause of the following exception:
core/tests/test_ryuk.py:58: in test_container_without_ryuk
    Reaper.delete_instance()
core/testcontainers/core/container.py:333: in delete_instance
    Reaper._container.stop()
core/testcontainers/core/container.py:212: in stop
    self._container.remove(force=force, v=delete_volume)
.venv/lib/python3.10/site-packages/docker/models/containers.py:367: in remove
    return self.client.api.remove_container(self.id, **kwargs)
.venv/lib/python3.10/site-packages/docker/utils/decorators.py:19: in wrapped
    return f(self, resource_id, *args, **kwargs)
.venv/lib/python3.10/site-packages/docker/api/container.py:1037: in remove_container
    self._raise_for_status(res)
.venv/lib/python3.10/site-packages/docker/api/client.py:277: in _raise_for_status
    raise create_api_error_from_http_exception(e) from e
.venv/lib/python3.10/site-packages/docker/errors.py:39: in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation) from e
E   docker.errors.APIError: 409 Client Error for http+docker://localhost/v1.54/containers/11c29242a3a66f2fc35fe87d8ccdf169c05af8b3a946bb823b7aa295b9bde314?v=True&link=False&force=True: Conflict ("removal of container 11c29242a3a66f2fc35fe87d8ccdf169c05af8b3a946bb823b7aa295b9bde314 is already in progress")
=============================== warnings summary ===============================
core/testcontainers/core/config.py:89
  /workspace/core/testcontainers/core/config.py:89: PytestCollectionWarning: cannot collect test class 'TestcontainersConfiguration' because it has a __init__ constructor (from: core/tests/test_config.py)
    @dataclass

.venv/lib/python3.10/site-packages/google/api_core/_python_version_support.py:275
  /workspace/.venv/lib/python3.10/site-packages/google/api_core/_python_version_support.py:275: FutureWarning: You are using a Python version (3.10.19) which Google will stop supporting in new releases of google.api_core once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.api_core past that date.
    warnings.warn(message, FutureWarning)

.venv/lib/python3.10/site-packages/google/api_core/_python_version_support.py:275
  /workspace/.venv/lib/python3.10/site-packages/google/api_core/_python_version_support.py:275: FutureWarning: You are using a Python version (3.10.19) which Google will stop supporting in new releases of google.cloud.datastore_v1 once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.cloud.datastore_v1 past that date.
    warnings.warn(message, FutureWarning)

.venv/lib/python3.10/site-packages/google/api_core/_python_version_support.py:275
  /workspace/.venv/lib/python3.10/site-packages/google/api_core/_python_version_support.py:275: FutureWarning: You are using a Python version (3.10.19) which Google will stop supporting in new releases of google.pubsub_v1 once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.pubsub_v1 past that date.
    warnings.warn(message, FutureWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED core/tests/test_ryuk.py::test_wait_for_reaper - Failed: DID NOT RAISE ...
FAILED core/tests/test_ryuk.py::test_container_without_ryuk - docker.errors.A...
===== 2 failed, 3 passed, 469 deselected, 1 xfailed, 4 warnings in 55.64s ======

Its seems like in past cases a timing issue with the containers cleanup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions