MacOS 安装和使用podman

生命不息 折腾不止

2020-02-03 看到一些文章说podman很棒, 大有取代docker之势, 而且只需要alias docker=podman就可以无缝切换. 本着要做就好好做, 精益求精的态度, 打算在新任务中就直接采用它.

大致命令如下

brew install podman
brew install --cask multipass  # 这是去github下载包来安装的, 有点慢, 耗时约0.5h
multipass version
# multipass  1.5.0+mac

multipass launch -c 2 -d 20G -m 2G -n podman  # 这一步实在很慢, 而且10多分钟后还报了超时的错误, 然后直接launch本地文件也报错了
# 直接launch报了Network timeout
# launch failed: failed to download from 'https://cloud-images.ubuntu.com/releases/server/releases/focal/release-20210201/ubuntu-20.04-server-cloudimg-amd64.img': Network timeout

# 用本地文件来launch(先到HW源复制下载路径)
wget https://repo.huaweicloud.com/ubuntu-cloud-images/focal/20210201/focal-server-cloudimg-amd64.img

 multipass launch -c 2 -d 20G -m 2G -n podman file://`pwd`/focal-server-cloudimg-amd64.img
# 报了如下错误
# launch failed: http and file based images are not supported

最后发现MacOS是不支持从本地文件launch的(GitHub上有人评论说Windows也不支持), github上维护者的原话是launch from local暂时只支持Linux系统 https://github.com/canonical/multipass/issues/1029#issuecomment-529126601

 

后来, 开了代理, 爬梯子, 终于还是launch成功了

echo '
export WAKET_IP="192.168.2.13"
export http_proxy="http://$WAKET_IP:8889"
export https_proxy="https://$WAKET_IP:8889"
export all_proxy="socks5://$WAKET_IP:1089"
' > be_proxy.sh
source be_proxy.sh
curl -I https://twitter.com


multipass launch -c 2 -d 20G -m 2G -n podman groovy

然后就是进入launch出来的虚拟机, 在里面安装和启动podman

multipass list
multipass shell podman
mkdir archives && cd archives && git clone https://gitee.com/waketzheng/carstino.git
cd carstino && sudo ./change_ubuntu_mirror_sources.sh
sudo apt update && sudo apt install -y podman
sudo apt install runc
sudo systemctl enable podman.socket --now

配置客户端连接

# 如果主机未配置公钥, 可执行: ssh-keygen -t rsa
multipass mount ~/.ssh podman
multipass info podman

multipass shell podman
cat /Users/mac/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
sudo su
cd
cat /Users/mac/.ssh/id_rsa.pub >> .ssh/authorized_keys

再回到主机上创建连接

podman system connection add ubuntu --identity ~/.ssh/id_rsa ssh://root@192.168.64.2/run/podman/podman.sock
podman system connection list
podman ps # 这句报错了
Error: server API version is too old. Client "2.0.0" server "1.0.0"

最终还是没能在mac上直接使用podman, 只能是`multipass shell podman` 然后到Ubuntu系统里使用它

后记(2021-02-10) 这是一个真香现场来着, 折腾了好几天(之前在ubuntu安装podman, 也很费时间, 最终都是升级到20.10版本才装上的), 最后还是用回docker了

# MacOS 
brew install --cask docker

# ubuntu
sudo apt install docker.io

参考文章:

https://zhuanlan.zhihu.com/p/330492705

https://multipass.run/docs/installing-on-macos

https://wenhan.blog/post/multipass-launch-failed-by-network-timeout/

https://www.cnblogs.com/luoxiaolei/p/10851882.html

https://www.techrepublic.com/article/how-to-share-data-between-host-and-vm-with-multipass/

 

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页