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 进行寻址,其中方案向客户端指示如何连接到服务。支持的方案有:http+sshhttp+unixtcp。格式如下所示

  • http+ssh://[<login>@]<hostname>[:<port>]/<完整的 文件系统 路径>

    • 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)

索引和表格