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

docker.images.push does not throw an exception on authentication failures #3277

Open
david0 opened this issue Aug 1, 2024 · 0 comments · May be fixed by #3286
Open

docker.images.push does not throw an exception on authentication failures #3277

david0 opened this issue Aug 1, 2024 · 0 comments · May be fixed by #3286

Comments

@david0
Copy link
Contributor

david0 commented Aug 1, 2024

when calling images.push, I would expect an exception if the push fails for any reason. Instead a list of strings containing json(!) is returned.

In my case this was caused by using a credentials that were able to read the repository, but not to write on it.
I am using docker-py 7.1.0.

>>> d.images.push('registry.devops.company.de/sdm/devenv/docker/nds22:DMT')
'{"status":"The push refers to repository [registry.devops.company.de/sdm/devenv/docker/nds22]"}\r\n{"status":"Preparing","progressDetail":{},"id":"e13fc22196f7"}\r\n{"status":"Preparing","progressDetail":{},"id":"d3f568e44044"}\r\n{"status":"Preparing","progressDetail":{},"id":"20d52c42c0d2"}\r\n{"status":"Preparing","progressDetail":{},"id":"3b970ba98564"}\r\n{"status":"Preparing","progressDetail":{},"id":"a3fe5767be1f"}\r\n{"status":"Preparing","progressDetail":{},"id":"dc056a2a3bd7"}\r\n{"status":"Preparing","progressDetail":{},"id":"94edc0573192"}\r\n{"status":"Preparing","progressDetail":{},"id":"190bd049e69a"}\r\n{"status":"Preparing","progressDetail":{},"id":"c1278f9a1d1a"}\r\n{"status":"Preparing","progressDetail":{},"id":"c1278f9a1d1a"}\r\n{"status":"Preparing","progressDetail":{},"id":"284b4e718772"}\r\n{"status":"Preparing","progressDetail":{},"id":"17f90e156a5c"}\r\n{"status":"Preparing","progressDetail":{},"id":"0c0d9af5e66d"}\r\n{"status":"Preparing","progressDetail":{},"id":"b1809d9a4ad6"}\r\n{"status":"Preparing","progressDetail":{},"id":"d24d1c4d4104"}\r\n{"status":"Preparing","progressDetail":{},"id":"06e6efc8f7ad"}\r\n{"status":"Waiting","progressDetail":{},"id":"dc056a2a3bd7"}\r\n{"status":"Waiting","progressDetail":{},"id":"94edc0573192"}\r\n{"status":"Preparing","progressDetail":{},"id":"79a69a8c6a35"}\r\n{"status":"Waiting","progressDetail":{},"id":"190bd049e69a"}\r\n{"status":"Preparing","progressDetail":{},"id":"6fb0da284158"}\r\n{"status":"Waiting","progressDetail":{},"id":"c1278f9a1d1a"}\r\n{"status":"Preparing","progressDetail":{},"id":"0d9950f614d6"}\r\n{"status":"Preparing","progressDetail":{},"id":"fb793371e751"}\r\n{"status":"Preparing","progressDetail":{},"id":"22f8be0594d4"}\r\n{"status":"Preparing","progressDetail":{},"id":"b6cfde0b8194"}\r\n{"status":"Preparing","progressDetail":{},"id":"fc39326d9866"}\r\n{"status":"Preparing","progressDetail":{},"id":"f3779f3ebb98"}\r\n{"status":"Preparing","progressDetail":{},"id":"e524eb3d960d"}\r\n{"status":"Preparing","progressDetail":{},"id":"33bf517fef8b"}\r\n{"status":"Waiting","progressDetail":{},"id":"284b4e718772"}\r\n{"status":"Preparing","progressDetail":{},"id":"eeb727f8e4bb"}\r\n{"status":"Waiting","progressDetail":{},"id":"17f90e156a5c"}\r\n{"status":"Waiting","progressDetail":{},"id":"0c0d9af5e66d"}\r\n{"status":"Preparing","progressDetail":{},"id":"e6ebdd044b9c"}\r\n{"status":"Waiting","progressDetail":{},"id":"b1809d9a4ad6"}\r\n{"status":"Waiting","progressDetail":{},"id":"d24d1c4d4104"}\r\n{"status":"Preparing","progressDetail":{},"id":"5817476c92af"}\r\n{"status":"Waiting","progressDetail":{},"id":"06e6efc8f7ad"}\r\n{"status":"Preparing","progressDetail":{},"id":"06590ea36d6c"}\r\n{"status":"Waiting","progressDetail":{},"id":"79a69a8c6a35"}\r\n{"status":"Preparing","progressDetail":{},"id":"508a97bc2a5f"}\r\n{"status":"Waiting","progressDetail":{},"id":"6fb0da284158"}\r\n{"status":"Waiting","progressDetail":{},"id":"22f8be0594d4"}\r\n{"status":"Waiting","progressDetail":{},"id":"f3779f3ebb98"}\r\n{"status":"Preparing","progressDetail":{},"id":"80f4edff0ff6"}\r\n{"status":"Waiting","progressDetail":{},"id":"fc39326d9866"}\r\n{"status":"Waiting","progressDetail":{},"id":"0d9950f614d6"}\r\n{"status":"Waiting","progressDetail":{},"id":"b6cfde0b8194"}\r\n{"status":"Waiting","progressDetail":{},"id":"fb793371e751"}\r\n{"status":"Waiting","progressDetail":{},"id":"e524eb3d960d"}\r\n{"status":"Waiting","progressDetail":{},"id":"5817476c92af"}\r\n{"status":"Waiting","progressDetail":{},"id":"e6ebdd044b9c"}\r\n{"status":"Preparing","progressDetail":{},"id":"be3202997979"}\r\n{"status":"Waiting","progressDetail":{},"id":"33bf517fef8b"}\r\n{"status":"Waiting","progressDetail":{},"id":"eeb727f8e4bb"}\r\n{"status":"Waiting","progressDetail":{},"id":"06590ea36d6c"}\r\n{"status":"Preparing","progressDetail":{},"id":"638f2a99f7f3"}\r\n{"status":"Waiting","progressDetail":{},"id":"508a97bc2a5f"}\r\n{"status":"Waiting","progressDetail":{},"id":"80f4edff0ff6"}\r\n{"status":"Preparing","progressDetail":{},"id":"1f6ca1411ece"}\r\n{"status":"Waiting","progressDetail":{},"id":"be3202997979"}\r\n{"status":"Preparing","progressDetail":{},"id":"5efb24c93836"}\r\n{"status":"Waiting","progressDetail":{},"id":"1f6ca1411ece"}\r\n{"status":"Preparing","progressDetail":{},"id":"c6fb32907cb8"}\r\n{"status":"Waiting","progressDetail":{},"id":"5efb24c93836"}\r\n{"status":"Preparing","progressDetail":{},"id":"9d92b36b6f8d"}\r\n{"status":"Waiting","progressDetail":{},"id":"c6fb32907cb8"}\r\n{"status":"Preparing","progressDetail":{},"id":"7bce3075df58"}\r\n{"status":"Waiting","progressDetail":{},"id":"9d92b36b6f8d"}\r\n{"status":"Preparing","progressDetail":{},"id":"bcf30f7550b0"}\r\n{"status":"Waiting","progressDetail":{},"id":"7bce3075df58"}\r\n{"status":"Preparing","progressDetail":{},"id":"74ddd0ec08fa"}\r\n{"status":"Waiting","progressDetail":{},"id":"bcf30f7550b0"}\r\n{"status":"Waiting","progressDetail":{},"id":"74ddd0ec08fa"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"20d52c42c0d2"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"e13fc22196f7"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"3b970ba98564"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"d3f568e44044"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"a3fe5767be1f"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"dc056a2a3bd7"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"c1278f9a1d1a"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"284b4e718772"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"190bd049e69a"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"94edc0573192"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"17f90e156a5c"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"0c0d9af5e66d"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"06e6efc8f7ad"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"d24d1c4d4104"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"b1809d9a4ad6"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"79a69a8c6a35"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"0d9950f614d6"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"6fb0da284158"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"22f8be0594d4"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"fb793371e751"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"b6cfde0b8194"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"fc39326d9866"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"f3779f3ebb98"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"e524eb3d960d"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"33bf517fef8b"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"eeb727f8e4bb"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"e6ebdd044b9c"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"5817476c92af"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"06590ea36d6c"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"508a97bc2a5f"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"80f4edff0ff6"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"1f6ca1411ece"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"be3202997979"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"638f2a99f7f3"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"5efb24c93836"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"c6fb32907cb8"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"9d92b36b6f8d"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"7bce3075df58"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"bcf30f7550b0"}\r\n{"status":"Layer already exists","progressDetail":{},"id":"74ddd0ec08fa"}\r\n{"errorDetail":{"message":"errors:\\ndenied: requested access to the resource is denied\\nunauthorized: authentication required\\n"},"error":"errors:\\ndenied: requested access to the resource is denied\\nunauthorized: authentication required\\n"}\r\n'
frazar added a commit to frazar/docker-py that referenced this issue Sep 13, 2024
Fixes: docker#3277

Signed-off-by: Francesco Zardi <frazar0@hotmail.it>
frazar added a commit to frazar/docker-py that referenced this issue Sep 14, 2024
Fixes: docker#3277

Signed-off-by: Francesco Zardi <frazar0@hotmail.it>
frazar added a commit to frazar/docker-py that referenced this issue Sep 14, 2024
When pushing an image, the server response might have status code
200 (OK) even though the operation has failed.

To detect the occurrence of an error, inspect each JSON chunk in
the server response and verify that no "error" field is present.

Fixes: docker#3277

Signed-off-by: Francesco Zardi <frazar0@hotmail.it>
frazar added a commit to frazar/docker-py that referenced this issue Sep 14, 2024
When pushing an image, the server response might have status code
200 (OK) even though the operation has failed.

To detect the occurrence of an error, inspect each JSON chunk in
the server response and verify that no "error" field is present.

Fixes: docker#3277

Signed-off-by: Francesco Zardi <frazar0@hotmail.it>
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

Successfully merging a pull request may close this issue.

1 participant