images¶
镜像资源的模型和管理器。
- class Image(attrs: Mapping[str, Any] | None = None, client: APIClient | None = None, collection: Manager | None = None, podman_client: PodmanClient | None = None)[source]¶
-
由 Podman 服务管理的镜像的详细信息和配置。
初始化 PodmanResource 的基类。
- 参数:
attrs – Podman 服务资源属性的映射。
client – Podman 服务的配置连接。
collection – 此类资源的管理器,为了兼容性命名为 collection
podman_client – 配置为连接到 Podman 对象的 PodmanClient()。
- 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。
- 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]