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

No method to try to pull an image, while handling gracefully #649

Open
gabriel-st-angel-aerospace opened this issue Nov 1, 2024 · 1 comment

Comments

@gabriel-st-angel-aerospace

First off I just wanted to express my gratitude for this library and all of the work that has gone into it. It's been very helpful for my project and is much cleaner than docker-py.

I am trying to write some logic to see if an image exists locally, then attempt to pull it if it doesn't, while handling everything gracefully.

docker.image.inspect() is great for checking if an image exists locally, proper error handling and doesn't muddy up stdout.

However, docker.pull() doesn't try to catch any exceptions and spits out some junk to stdout.

I propose a try/catch around docker.pull that raises a NoSuchImage if the pull fails.

@gabrieldemarmiesse
Copy link
Owner

First of all, many thanks for the kind words, those are what keep the maintainers going!

Second, that would be a great addition to python-on-whales to have specific exceptions in docker.pull() depending on the reasons for failure. We can get the information from stderr or from the exit code (if the exit code differs depending on the reason for failing). I'm open for pull requests in this direction as long as it doesn't complexify the codebase too much!

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