在MacOS中,Podman的底层由QEMU虚拟机支持。虚拟机中启动了一个Linux系统,称为podman机器。可用用 podman machine 命令管理。
brew install podman
podman machine init
podman machine start
podman info
brew install podman-desktop
pip3 install podman-compose
MacOS 中,podman安装在虚拟机中,修改镜像配置文件要登录虚拟机中修改。registries.conf 用于指定默认的容器仓库,拉取没有仓库名的镜像时会使用默认容器仓库,配置文件位于以下位置:
全局配置文件:
/etc/containers/registries.conf
用户配置文件:
$HOME/.config/containers/registries.conf
非root用户可以使用用户配置文件替换系统默认配置。如果设置了 CONTAINERS_REGISTRIES_CONF 环境变量,则使用该变量的设置。
配置文件为TOML格式,容器引擎会先选择用户配置文件,如果不存在就使用全局配置文件。配置例子:
# 拉取镜像时没有指定仓库地址,按这里的仓库列表顺序搜索镜像
unqualified-search-registries = ["example.com"]
[[registry]]
prefix = "example.com/foo"
insecure = false
blocked = false
location = "internal-registry-for-example.com/bar"
[[registry.mirror]]
location = "example-mirror-0.local/mirror-for-foo"
[[registry.mirror]]
location = "example-mirror-1.local/mirrors/foo"
insecure = true
[[registry]]
location = "registry.com"
[[registry.mirror]]
location = "mirror.registry.com"
当拉取 example.com/foo/image:latest 时,会按以下顺序尝试拉取,并且使用第一个存在的镜像。
每次删除虚拟机后都要重新进虚拟机修改镜像配置,可以挂载主机的配置到虚拟机中。
podman machine init -v $HOME/.config/containers/registries.conf:/var/home/core/.config/containers/registries.conf:ro
podman machine ssh
touch $HOME/.config/containers/registries.conf
unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
location = "docker.io"
[[registry.mirror]]
location = "hub-mirror.c.163.com"
[[registry.mirror]]
location = "mirror.baidubce.com"
[[registry.mirror]]
location = "ustc-edu-cn.mirror.aliyuncs.com"
[[registry.mirror]]
location = "registry.docker-cn.com"
➜ ~ podman info | grep registries -A 25
registries:
docker.io:
Blocked: false
Insecure: false
Location: docker.io
MirrorByDigestOnly: false
Mirrors:
- Insecure: false
Location: hub-mirror.c.163.com
PullFromMirror: ""
- Insecure: false
Location: mirror.baidubce.com
PullFromMirror: ""
- Insecure: false
Location: ustc-edu-cn.mirror.aliyuncs.com
PullFromMirror: ""
- Insecure: false
Location: registry.docker-cn.com
PullFromMirror: ""
Prefix: docker.io
PullFromMirror: ""
search:
- docker.io
store:
configFile: /var/home/core/.config/containers/storage.conf
containerStore: