Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support login to Docker Hub, to avoid throttling #86

Open
neil-greenwood opened this issue Feb 3, 2021 · 2 comments
Open

Support login to Docker Hub, to avoid throttling #86

neil-greenwood opened this issue Feb 3, 2021 · 2 comments

Comments

@neil-greenwood
Copy link

We're seeing intermittent failures when using tox-docker 2.0.0:

2021-02-03 10:50:52 GMT+00:00 - Traceback (most recent call last):
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/docker/api/client.py", line 268, in _raise_for_status
2021-02-03 10:50:52 GMT+00:00 - response.raise_for_status()
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 943, in raise_for_status
2021-02-03 10:50:52 GMT+00:00 - raise HTTPError(http_error_msg, response=self)
2021-02-03 10:50:52 GMT+00:00 - requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.32/images/amazon/dynamodb-local:latest/json
2021-02-03 10:50:52 GMT+00:00 -
2021-02-03 10:50:52 GMT+00:00 - During handling of the above exception, another exception occurred:
2021-02-03 10:50:52 GMT+00:00 -
2021-02-03 10:50:52 GMT+00:00 - Traceback (most recent call last):
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/tox_docker/__init__.py", line 256, in tox_runtest_pre
2021-02-03 10:50:52 GMT+00:00 - docker.images.get(image)
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/docker/models/images.py", line 316, in get
2021-02-03 10:50:52 GMT+00:00 - return self.prepare_model(self.client.api.inspect_image(name))
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/docker/utils/decorators.py", line 19, in wrapped
2021-02-03 10:50:52 GMT+00:00 - return f(self, resource_id, *args, **kwargs)
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/docker/api/image.py", line 254, in inspect_image
2021-02-03 10:50:52 GMT+00:00 - self._get(self._url("/images/{0}/json", image)), True
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/docker/api/client.py", line 274, in _result
2021-02-03 10:50:52 GMT+00:00 - self._raise_for_status(response)
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/docker/api/client.py", line 270, in _raise_for_status
2021-02-03 10:50:52 GMT+00:00 - raise create_api_error_from_http_exception(e)
2021-02-03 10:50:52 GMT+00:00 - File "/usr/local/lib/python3.6/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
2021-02-03 10:50:52 GMT+00:00 - raise cls(e, response=response, explanation=explanation)
2021-02-03 10:50:52 GMT+00:00 - docker.errors.ImageNotFound: 404 Client Error for http+docker://localhost/v1.32/images/amazon/dynamodb-local:latest/json: Not Found ("no such image: amazon/dynamodb-local:latest: No such image: amazon/dynamodb-local:latest")

I guess these are caused by the throttling of unauthenticated pulls from hub.docker.com

@neil-greenwood
Copy link
Author

neil-greenwood commented Feb 3, 2021

Maybe something like this (and storing the appropriate parameters):

$ git diff
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
modified: tox_docker/__init__.py
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@ tox_docker/__init__.py:260 @ def tox_runtest_pre(venv):  # noqa: C901
         except ImageNotFound:
             action.setactivity("docker", f"pull {image!r} (from {container_name!r})")
             with action:
+                if 'username' in envconfig.docker:
+                    docker.login(envconfig.docker['username'], envconfig.docker['password'])
                 docker.images.pull(name, tag=tag or None)

     envconfig._docker_containers = {}

I think that leaves the password in cleartext though, which I don't like.

@frafra
Copy link

frafra commented Sep 19, 2023

Wouldn't it be better to rely on the existing ~/.docker/config.json generated by docker login?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants