Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/containers/podman-py
Python bindings for Podman's RESTful API
https://github.com/containers/podman-py
libpod podman python
Last synced: about 9 hours ago
JSON representation
Python bindings for Podman's RESTful API
- Host: GitHub
- URL: https://github.com/containers/podman-py
- Owner: containers
- License: apache-2.0
- Created: 2020-02-01T16:19:43.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-11-13T03:22:41.000Z (about 20 hours ago)
- Last Synced: 2024-11-13T04:23:49.680Z (about 19 hours ago)
- Topics: libpod, podman, python
- Language: Python
- Homepage:
- Size: 1020 KB
- Stars: 255
- Watchers: 14
- Forks: 95
- Open Issues: 31
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE-OF-CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# podman-py
[![Build Status](https://api.cirrus-ci.com/github/containers/podman-py.svg)](https://cirrus-ci.com/github/containers/podman-py/main)This python package is a library of bindings to use the RESTful API of [Podman](https://github.com/containers/podman).
It is currently under development and contributors are welcome!## Dependencies
* For runtime dependencies, see [requirements.txt](https://github.com/containers/podman-py/blob/main/requirements.txt).
* For testing and development dependencies, see [test-requirements.txt](https://github.com/containers/podman-py/blob/main/test-requirements.txt).## Example usage
```python
"""Demonstrate PodmanClient."""
import json
from podman import PodmanClient# 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 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():
# After a list call you would probably want to reload the container
# to get the information about the variables such as status.
# Note that list() ignores the sparse option and assumes True by default.
container.reload()
print(container, container.id, "\n")
print(container, container.status, "\n")# available fields
print(sorted(container.attrs.keys()))print(json.dumps(client.df(), indent=4))
```## Contributing
See [CONTRIBUTING.md](https://github.com/containers/podman-py/blob/main/CONTRIBUTING.md)