testcontainers / moby-ryuk

Schedule Moby/Docker containers cleanup after specific delay.
https://www.testcontainers.com
MIT License
192 stars 35 forks source link

testcontainer python runs with version 0.10.x ++ fails in macos m1 #177

Open debu999 opened 5 hours ago

debu999 commented 5 hours ago

following is the configuraration

import pytest

os.environ["RYUK_CONTAINER_IMAGE"] = "testcontainers/ryuk:0.9.0"

from testcontainers.kafka import RedpandaContainer

@pytest.fixture(scope="session") def kafka_container(): with RedpandaContainer( image="docker.redpanda.com/redpandadata/redpanda:v24.2.11" ) as redpanda: bootstrap_server = redpanda.get_bootstrap_server() yield {"bootstrap_servers": bootstrap_server} #

def test_multiply(kafka_container): assert 5 == 10 // 2 bs = kafka_container["bootstrap_servers"] print(bs)


- 0.10.0/0.10.1/0.10.2/0.11.0 etc fails

import os

import pytest

os.environ["RYUK_CONTAINER_IMAGE"] = "testcontainers/ryuk:0.10.0"

from testcontainers.kafka import RedpandaContainer

@pytest.fixture(scope="session") def kafka_container(): with RedpandaContainer( image="docker.redpanda.com/redpandadata/redpanda:v24.2.11" ) as redpanda: bootstrap_server = redpanda.get_bootstrap_server() yield {"bootstrap_servers": bootstrap_server} #

def test_multiply(kafka_container): assert 5 == 10 // 2 bs = kafka_container["bootstrap_servers"] print(bs)


Error details

==================== 1 warning, 1 error in 71.20s (0:01:11) ==================== ERROR [100%]Pulling image testcontainers/ryuk:0.10.0 Container started: 8e5bae5b0aa5

test setup failed self = <docker.api.client.APIClient object at 0x104a40b90> response = <Response [404]>

def _raise_for_status(self, response):
    """Raises stored :class:`APIError`, if one occurred."""
    try:
      response.raise_for_status()

/Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/api/client.py:275:


self = <Response [404]>

def raise_for_status(self):
    """Raises :class:`HTTPError`, if one occurred."""

    http_error_msg = ""
    if isinstance(self.reason, bytes):
        # We attempt to decode utf-8 first because some servers
        # choose to localize their reason strings. If the string
        # isn't utf-8, we fall back to iso-8859-1 for all other
        # encodings. (See PR #3538)
        try:
            reason = self.reason.decode("utf-8")
        except UnicodeDecodeError:
            reason = self.reason.decode("iso-8859-1")
    else:
        reason = self.reason

    if 400 <= self.status_code < 500:
        http_error_msg = (
            f"{self.status_code} Client Error: {reason} for url: {self.url}"
        )

    elif 500 <= self.status_code < 600:
        http_error_msg = (
            f"{self.status_code} Server Error: {reason} for url: {self.url}"
        )

    if http_error_msg:
      raise HTTPError(http_error_msg, response=self)

E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.44/containers/8e5bae5b0aa5bc78ead931e57d4d4edccfb02d52ec011e6933b1691e09787740/json

/Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/requests/models.py:1024: HTTPError

The above exception was the direct cause of the following exception:

@pytest.fixture(scope="session")
def kafka_container():
with RedpandaContainer(

image="docker.redpanda.com/redpandadata/redpanda:v24.2.11" ) as redpanda:

test_messaging.py:12:


/Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/testcontainers/core/container.py:126: in enter return self.start() /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/testcontainers/kafka/_redpanda.py:70: in start super().start() /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/testcontainers/core/container.py:89: in start Reaper.get_instance() /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/testcontainers/core/container.py:207: in get_instance Reaper._instance = Reaper._create_instance() /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/testcontainers/core/container.py:238: in _create_instance wait_for_logs(Reaper._container, r".* Started!") /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/testcontainers/core/waiting_utils.py:109: in wait_for_logs stdout = container.get_logs()[0].decode() /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/testcontainers/core/container.py:187: in get_logs return self._container.logs(stderr=False), self._container.logs(stdout=False) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/models/containers.py:322: in logs return self.client.api.logs(self.id, kwargs) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/utils/decorators.py:19: in wrapped return f(self, resource_id, *args, *kwargs) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/api/container.py:896: in logs output = self._get_result(container, stream, res) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/api/client.py:483: in _get_result return self._get_result_tty(stream, res, self._check_is_tty(container)) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/utils/decorators.py:19: in wrapped return f(self, resource_id, args, kwargs) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/api/client.py:479: in _check_is_tty cont = self.inspect_container(container) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/utils/decorators.py:19: in wrapped return f(self, resource_id, *args, **kwargs) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/api/container.py:793: in inspect_container return self._result( /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/api/client.py:281: in _result self._raise_for_status(response) /Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/api/client.py:277: in _raise_for_status raise create_api_error_from_http_exception(e) from e


e = HTTPError('404 Client Error: Not Found for url: http+docker://localhost/v1.44/containers/8e5bae5b0aa5bc78ead931e57d4d4edccfb02d52ec011e6933b1691e09787740/json')

def create_api_error_from_http_exception(e):
    """
    Create a suitable APIError from requests.exceptions.HTTPError.
    """
    response = e.response
    try:
        explanation = response.json()['message']
    except ValueError:
        explanation = (response.text or '').strip()
    cls = APIError
    if response.status_code == 404:
        explanation_msg = (explanation or '').lower()
        if any(fragment in explanation_msg
               for fragment in _image_not_found_explanation_fragments):
            cls = ImageNotFound
        else:
            cls = NotFound
  raise cls(e, response=response, explanation=explanation) from e

E docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.44/containers/8e5bae5b0aa5bc78ead931e57d4d4edccfb02d52ec011e6933b1691e09787740/json: Not Found ("No such container: 8e5bae5b0aa5bc78ead931e57d4d4edccfb02d52ec011e6933b1691e09787740")

/Users/../Library/Caches/pypoetry/virtualenvs/github-actions-utils-3raOMR1u-py3.13/lib/python3.13/site-packages/docker/errors.py:39: NotFound

Process finished with exit code 1

debu999 commented 5 hours ago

Same with latest docker version

>        raise HTTPError(http_error_msg, response=self)
E       requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.47/containers/30d4dd0a66cb900c585da15a0614e87ea1539ca6b196cccd456b11a158e03b1a/json