博客再次改版了,这次在细节方面做了一些调整。
MacOS docker desktop 替代之 Podman
时间:2022-03-23 21:25:20 +0800 CST 浏览:102

安装虚拟机

# 本机运行
brew install multipass --cask
# 创建一个虚拟机
multipass launch -c 2 -d 20G -m 2G -n podman 20.04
# 启动虚拟机
multipass shell podman

虚拟机运行

sudo sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
. /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install podman


# config first connection
# enabl podman service: 依赖 systemd 的 socket activation 特性
sudo systemctl cat podman.socket
sudo systemctl cat podman.service
sudo systemctl enable podman.socket --now
# 确认 podman.socket 是否开启成功
podman info

# 加速
sudo vim /etc/containers/registries.conf
unqualified-search-registries = ["docker.io"]
# 从location的地址中拉取docker.io的镜像
[[registry]]
# 匹配哪个地址,触发location
prefix = "docker.io"
# 此处的url不能有http前缀
location = "si7y70hh.mirror.aliyuncs.com"

ssh秘钥

将MacOS的公钥添加到podman虚拟机的root账户下

podman remote

# 本机运行
# podman client
wget  https://github.com/containers/podman/releases/download/v3.4.2/podman-remote-release-darwin.zip
# IP查看根据实际情况变动(虚拟机IP)
podman system connection add podman --identity ~/.ssh/id_rsa ssh://root@192.168.64.2/run/podman/podman.sock
podman system connection list
# 骚操作
alias docker=podman


如果这篇文章对你有所帮助,可以通过下边的“打赏”功能进行小额的打赏。

本网站部分内容来源于互联网,如有侵犯版权请来信告知,我们将立即处理。


来说两句吧