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

Wrapper for podman pull? #104

Closed
vsoch opened this issue May 30, 2021 · 4 comments
Closed

Wrapper for podman pull? #104

vsoch opened this issue May 30, 2021 · 4 comments

Comments

@vsoch
Copy link

vsoch commented May 30, 2021

I'm interested in a python client for podman that is more of a wrapper, e.g., allows me to pull a container from Python. Is this something that this library could support? From what I can see, it looks like the client here is intended to interact with the local socket (e.g., I can get containers / manifests that I've already pulled). It's fairly simple to use subprocess to interact with podman directly, but it would be great if the support was provided here! And if it's not and is not planned to, is there a reason why?

@vsoch
Copy link
Author

vsoch commented May 30, 2021

I did find images.pull, but it doesn't seem to work:

self.client.images.pull('docker.io/vanessa/salad')
~/Desktop/Code/singularity-hpc/env/lib/python3.8/site-packages/podman/api/client.py in post(self, path, params, data, headers, timeout, stream, **kwargs)
    302             APIError: when service returns an error
    303         """
--> 304         return self._request(
    305             "POST",
    306             path=path,

~/Desktop/Code/singularity-hpc/env/lib/python3.8/site-packages/podman/api/client.py in _request(self, method, path, data, params, headers, timeout, stream, **kwargs)
    411             )
    412         except OSError as e:
--> 413             raise APIError(uri.geturl(), explanation=f"{method.upper()} operation failed") from e

APIError: http://%2Frun%2Fuser%2F1000%2Fpodman%2Fpodman.sock/v3.1.2/libpod/images/pull (POST operation failed)

podman works locally on my host, however (I really like the interface!)

 podman pull vanessa/salad
? Please select an image: 
  ▸ docker.io/vanessa/salad:latest
    quay.io/vanessa/salad:latest

@bguezzie
Copy link

bguezzie commented Jun 8, 2021

Got details on the underlying OS error? Did you enable the socket? I've found that the first time I try to connect to the socket, it times out (like the newly spun-up podman process on the other end isn't fully "awake" yet). However, that seems to be a one-time thing and future requests work well.

@jwhonce
Copy link
Member

jwhonce commented Jun 8, 2021

@vsoch Pulling images is supported via podman-py. From the integration test that is run before each PR merge:

        with self.subTest("Pull Alpine Image"):
            image = self.client.images.pull("quay.io/libpod/alpine", tag="latest")
            self.assertIsInstance(image, Image)
            self.assertIn("quay.io/libpod/alpine:latest", image.tags)
            self.assertTrue(self.client.images.exists(image.id))

Please check your user journal for errors. Thanks.

@vsoch
Copy link
Author

vsoch commented Jun 8, 2021

I wound up just implementing a Docker controller (very simple with subprocess) that podman inherits: https://github.com/singularityhub/singularity-hpc/blob/main/shpc/main/container/podman.py. I wonder if the issue is that I wasn't doing the operation under that context - if the podman client really only works under that context, it could be error prone for users that expect self.client.<command> to just work. And tests are good examples (that exact test is where I discovered self.client.images.pull, but if you have some time I'd strongly suggest some documentation that walks the user through each of the expected commands. In other words, we shouldn't need to dig through tests or the source code to know how to use the library.

This is no longer an issue so happy to close!

@vsoch vsoch closed this as completed Jun 8, 2021
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

3 participants