Mac M1 安装colima,替代Docker for mac Desktop

Dcoker for mac Desktop 开始对规模较大的公司不再免费,colima 可以作为其替代品
https://github.com/abiosoft/colima
安装colima时,会一并安装qemu和lima,由于当前colima自动安装的qemu版本在mac m1下启动有问题,所以我们采用手动安装qemu和lima

  1. 安装qemu
    推荐安装最新版本v6.2.0版本的qemu
git clone https://gitlab.com/qemu-project/qemu.git
git checkout v6.2.0
mkdir build
cd build
../configure
make
sudo make install

安装完成后,有qemu-system-aarch64、qemu-system-arm等文件

  1. 安装lima
    https://github.com/lima-vm/lima
    下载lima v0.8.2二进制文件,放到对应的目录下
    或者使用如下命令可以一键完成安装
brew install jq
VERSION=$(curl -fsSL https://api.github.com/repos/lima-vm/lima/releases/latest | jq -r .tag_name)
curl -fsSL https://github.com/lima-vm/lima/releases/download/${VERSION}/lima-${VERSION:1}-$(uname -s)-$(uname -m).tar.gz | tar Cxzvm /usr/local
  1. 安装colima
    https://github.com/abiosoft/colima/releases/tag/v0.3.2
    下载colima二进制文件,放到bin目录下
    4.使用lima启动虚机,并安装docker和kubernetes
colima start --with-kubernetes --cpu 2 --memory 4

问题:colima error provisioning kubernetes: error at 'downloading and installing': exit status 1
colima ssh 登录虚机,手动安装k8s
下载 https://github.com/k3s-io/k3s/blob/master/install.sh,手动执行,安装成功后,再去启动colima
colima start --with-kubernetes --cpu 2 --memory 4
问题:error starting kubernetes: error at 'updating config': error fetching kubeconfig on guest: exit status 1
登录虚机拷贝/etc/rancher/k3s/k3s.yaml 文件到mac下的.kube/config中,即可使用kubectl了,可以忽略改错误

  1. 安装docker-client、kubectl
brew install docker kubectl
  1. 验证
# 执行docker 不报错
docker ps 
# 执行kubectl 能获取到节点
kubectl get nodes
NAME     STATUS   ROLES                  AGE   VERSION
colima   Ready    control-plane,master   41m   v1.22.6+k3s1
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容