Podman: 适用于 Podman 服务的 Python 脚本

https://img.shields.io/pypi/l/podman.svg https://img.shields.io/pypi/wheel/podman.svg https://img.shields.io/pypi/pyversions/podman.svg

PodmanPy 是一个 Python3 模块,允许您编写访问 Podman 服务所维护资源的 Python 脚本。它利用了 Podman 服务的 RESTful API。

Podman 服务通过 URL 进行寻址,URL 中的方案(scheme)向客户端指示如何连接到服务。支持的方案有:http+sshhttp+unixtcp。格式如下:

  • http+ssh://[<登录名>@]<主机名>[:<端口>]/<完整 文件系统 路径>

    • http+ssh://alice@api.example:22/run/user/1000/podman/podman.sock

    • 方案 ssh 可作为别名

  • http+unix://<完整 文件系统 路径>

    • http+unix:///run/podman/podman.sock

    • 方案 unix 可作为别名

  • tcp://<主机名>:<端口>

    • tcp://api.example:8888

示例

1import podman
2
3with podman.PodmanClient() as client:
4    if client.ping():
5        images = client.images.list()
6        for image in images:
7            print(image.id)

索引和表格