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
Ubuntu 默认安装的版本是3.4.4 在启动的时候会抱错:
Error: unable to start host networking: "could not find \"gvproxy\" in one of [/usr/local/libexec/podman /usr/local/lib/podman /usr/libexec/podman /usr/lib/podman]"
尝试安装最新版本的podman,官方安装文档: https://podman.io/getting-started/installation
文档说明,podman 的安装包是放在 opensuse.org 这个网站上的,但是安装包存放的目录已经发生了变化,大家根据自己的实际环境进行安装。不会的,抄下面作业:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/Release.key \
| gpg --dearmor \
| sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\
https://download.opensuse.org/repositories/devel:kubic:libcontainers:unstable/xUbuntu_22.04/ /" \
| sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null
sudo apt-get update -qq
sudo apt-get -y install podman
在启动 vm machine 时,有可能抱错: Permission denied
$ podman machine start
Starting machine "podman-machine-default"
Waiting for VM ...
Error: qemu exited unexpectedly with exit code 1, stderr: Could not access KVM kernel module: Permission denied
qemu-system-x86_64: -accel kvm: failed to initialize kvm: Permission denied
官方推荐的做法是将当前系统用户添加到 kvm 用户组中,但是我本机还没有 kvm 用户组,所以直接给 /dev/kvm
加 666 权限: sudo chmod 666 /dev/kvm
系统中如果存在 kvm group,可以尝试如下命令
sudo usermod -a -G kvm "yourUserName"
sudo usermod -a -G libvirtd "yourUserName"
容器启动后,通过port mapping, 已经看到该port listen。telnet localhost port
没有问题,但是 telnet IP port
死活不同,无语……
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 list
/Users/wakun/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-37.20221211.2.0-qemu.x86_64.qcow2x
/Users/wakun/.config/containers/podman/machine/qemu
podman machine set --help
podman machine ssh podman-machine-default
目前DockerHub pull image会限制速度,中科大的mirror 已经暂停外部访问。
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
/etc/containers/registries.conf
或者 /etc/containers/registries.conf.d/999-podman-machine.conf
配置文件,增加如下[[registry]]
location = "docker.io"
[[registry.mirror]]
location = "xxx.mirror.aliyuncs.com"
一开始本低 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