images

镜像资源的模型和管理器。

class Image(attrs: Mapping[str, Any] | None = None, client: APIClient | None = None, collection: Manager | None = None, podman_client: PodmanClient | None = None)[source]

基类:PodmanResource

由 Podman 服务管理的镜像的详细信息和配置。

初始化 PodmanResource 的基类。

参数:
  • attrs – Podman 服务资源属性的映射。

  • client – Podman 服务的配置连接。

  • collection – 此类资源的管理器,为了兼容性命名为 collection

  • podman_client – 配置为连接到 Podman 对象的 PodmanClient()。

history() list[dict[str, Any]][source]

返回镜像的历史记录。

抛出:

APIError – 服务返回错误时

reload(**kwargs) None

从服务刷新此对象的数据。

关键字参数:

compatible (bool) – 使用 Docker 兼容端点

remove(**kwargs) list[dict[Literal['Deleted', 'Untagged', 'Errors', 'ExitCode'], str | int]][source]

从 Podman 服务中删除镜像。

仅限 Podman

关键字参数:
  • force – 即使镜像正在使用中也删除它

  • noprune – 忽略。

返回:

报告哪些镜像被删除和取消标签,包括任何报告的错误。

抛出:
  • ImageNotFound – 当镜像不存在时

  • APIError – 服务返回错误时

save(chunk_size: int | None = 2097152, named: str | bool = False) Iterator[bytes][source]

以 tarball 形式返回镜像。

格式设置为 docker-archive,这允许 load() 导入此 tarball。

参数:
  • chunk_size – 如果为 None,数据将以接收到的缓冲区大小流式传输。如果不是 None,数据将以指定大小的缓冲区返回。默认值:2MB

  • named (strbool) – 如果为 False (默认值),tarball 将不保留此镜像的仓库和标签信息。如果设置为 Truetags 列表中的第一个标签将用于识别镜像。另外,tags 列表的任何元素都可以作为参数使用,以使用该特定标签作为保存的标识符。

抛出:
  • APIError – 当服务返回错误时

  • InvalidArgument – 当提供的标签名称对镜像无效时。

tag(repository: str, tag: str | None, force: bool = False) bool[source]

将镜像标记到仓库中。

参数:
  • repository – 用于标记镜像的仓库。

  • tag – 可选的标签名称。

  • force – 忽略客户端错误

返回:

操作成功时为 True。

抛出:
  • ImageNotFound – 当服务找不到镜像时

  • APIError – 服务返回错误时

property id

返回对象的标识符。

类型:

str

property labels

返回与镜像关联的标签。

类型:

dict[str, str]

manager: ImagesManager
property short_id

返回截断的标识符。当包含在 id 中时,保留“sha256”。

不尝试确保返回的值对所有资源都具有语义意义。

类型:

str

property tags

从镜像返回标签。

类型:

list[str]