Created
October 22, 2022 13:03
-
-
Save nicolargo/b9e6bd079b07fe64cb8c9b798a219cb0 to your computer and use it in GitHub Desktop.
Test podman (Python API)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Demonstrate PodmanClient.""" | |
import podman | |
# Provide a URI path for the libpod service. In libpod, the URI can be a unix | |
# domain socket(UDS) or TCP. The TCP connection has not been implemented in this | |
# package yet. | |
uri = "unix:///run/user/1000/podman/podman.sock" | |
with podman.PodmanClient(base_url=uri) as client: | |
version = client.version() | |
print("Release: ", version["Version"]) | |
print("Compatible API: ", version["ApiVersion"]) | |
print("Podman API: ", version["Components"][0]["Details"]["APIVersion"], "\n") | |
# get all images | |
for image in client.images.list(): | |
print(image, image.id, "\n") | |
# find all containers | |
for container in client.containers.list(): | |
# available fields | |
print("=" * 80) | |
# print(sorted(container.attrs.keys())) | |
for key in sorted(container.attrs.keys()): | |
print(key, container.attrs[key]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment