3.2. 配置容器注册表
您可以使用 podman info --format 命令显示容器注册中心:
podman info 命令在 Podman 4.0.0 或更高版本中提供。
您可以编辑 registries.conf 配置文件中容器注册中心的列表。以 root 用户身份,编辑 /etc/containers/registries.conf 文件,来更改默认的系统范围的搜索设置。
以用户身份,创建 $HOME/.config/containers/registries.conf 文件来覆盖系统范围的设置。
unqualified-search-registries = ["registry.access.redhat.com", "registry.redhat.io", "docker.io"] short-name-mode = "enforcing"
unqualified-search-registries = ["registry.access.redhat.com", "registry.redhat.io", "docker.io"]
short-name-mode = "enforcing"
默认情况下,podman pull 和 podman search 命令以指定顺序在 unqualified-search-registries 列表中列出的注册表中搜索容器镜像。
- 配置本地容器注册中心
您可以配置没有 TLS 验证的本地容器注册表。关于如何禁用 TLS 验证,您有两个选项。首先,您可以在 Podman 中使用
--tls-verify=false选项。其次,您可以在registry.conf文件中设置insecure=true:[[registry]] location="localhost:5000" insecure=true
[[registry]] location="localhost:5000" insecure=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 阻止注册表、命名空间或镜像
您可以定义不允许本地系统访问的注册表。您可以通过设置
blocked=true来阻止特定的注册中心。[[registry]] location = "registry.example.org" blocked = true
[[registry]] location = "registry.example.org" blocked = trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow 您也可以通过设置前缀
prefix="registry.example.org/namespace"来阻止命名空间。例如,使用podman pull registry. example.org/example/image:latest命令拉取镜像会被阻止,因为指定的前缀匹配了。[[registry]] location = "registry.example.org" prefix="registry.example.org/namespace" blocked = true
[[registry]] location = "registry.example.org" prefix="registry.example.org/namespace" blocked = trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow 注意prefix是可选的,默认值与location值相同。您可以通过设置
prefix="registry.example.org/namespace/image"来阻止特定的镜像。[[registry]] location = "registry.example.org" prefix="registry.example.org/namespace/image" blocked = true
[[registry]] location = "registry.example.org" prefix="registry.example.org/namespace/image" blocked = trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 镜像注册表
您可以设置一个注册中心镜像,以便在无法访问原始注册中心时访问。例如,您无法连接到互联网,因为您在高度敏感的环境中工作。您可以指定按照指定顺序联系的多个镜像。例如,当运行
podman pull registry.example.com/myimage:latest命令时,首先会尝试mirror-1.com,然后是mirror-2.com。Copy to Clipboard Copied! Toggle word wrap Toggle overflow