Install
Install Link
brew install podman
podman machine init
podman machine start
podman machine init --cpus=4 --disk-size=64 --memory=6144
podman machine start podman-machine-default
开启和关闭root 权限
Tips: 切换root 模式前后,相互看不到对方模式下的Images
podman machine set --rootful
podman machine set --rootful=false
podman system connection list Name URI Identity Default
podman-machine-default ssh://core@localhost:62426/run/user/110553204/podman/podman.sock /Users/wakun/.ssh/podman-machine-default false
podman-machine-default-root ssh://root@localhost:62426/run/podman/podman.sock /Users/wakun/.ssh/podman-machine-default true
The system helper service is not installed; the default Docker API socket
address can't be used by podman. If you would like to install it run the
following commands:
sudo /usr/local/Cellar/podman/4.1.1/bin/podman-mac-helper install
podman machine stop; podman machine start
You can still connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:
export DOCKER_HOST='unix:///Users/wakun/.local/share/containers/podman/machine/podman-machine-default/podman.sock'
Podman machine 管理
- 查看创建的虚拟机
podman machine list
- 虚拟机在本地磁盘存储位置:
/Users/wakun/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-37.20221211.2.0-qemu.x86_64.qcow2x
- 通过 qemu 启动的虚拟机配置 :
/Users/wakun/.config/containers/podman/machine/qemu
- 修改虚拟机硬件配置 :
podman machine set --help
- 进入虚拟机,可以sudo 到 root 账号 :
podman machine ssh podman-machine-default
Pull Image 加速
目前DockerHub pull image会限制速度,中科大的mirror 已经暂停外部访问。
通过 Ucloud 容器镜像库进行加速
Link: https://console.ucloud.cn/uhub/uhub/accelerate_image
通过 创建加速任务 创建需要pull 的image mirror。本地login ucloud repo podman login uhub.service.ucloud.cn
之后,就可以pull 对应的 ucloud image mirror
通过阿里云镜像加速下载
- 进入podman machine 内部,修改
/etc/containers/registries.conf
或者/etc/containers/registries.conf.d/999-podman-machine.conf
配置文件,增加如下
[[registry]]
location = "docker.io"
[[registry.mirror]]
location = "xxx.mirror.aliyuncs.com"
Troubleshooting
Homebrew 没有更新导致下载的qemu 版本低,虚拟机无法启动
一开始本低 Homebrew 没有更新,podman 依赖的 qemu 7.0.0_1
版本过低,这个版本的qemu 有Bug。更新Homebrew 后,https://github.com/Homebrew/homebrew-core/blob/master/Formula/qemu.rb 版本升级到 qemu--7.2.0.monterey.bottle.tar.gz
之后启动正常。Double check 本低的 qemu 版本号: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/qemu.rb