# 注意: 强烈不推荐 开始k8s --kubernetes,CPU使用率会非常高, k8s 可以使用 kind
colima start [--kubernetes] --network-address --vm-type=vz --mount-type=virtiofs --cpu 2 --memory 4 --disk 100 --mount-inotify=false --mount /Volumes/eWORK:wbrew install docker-credential-helper docker- edit
~/.docker/config.json{ "auths": {}, "credsStore": "osxkeychain", "currentContext": "colima" } brew install colima- parameters:
--mount /Volumes/WORK:wthis is very important, you must make some Volumn writable which you want to mount--network-addressmechanism for OSX , it asks for an admin pwd to be able to work.--mount-type=virtiofsvirtiofs is limited to macOS and vmTypevz. It is the fastest of the options.- 换成
--mount-type=reverse-sshfs可以避免 macOS 的 FSEvents 监控导致cpu使用率过高, 但是会稍微慢一些 - 也可以配合
--mount-inotify=false直接不扫描宿主目录变化
- 换成
- 另外一个可以有效降低cpu使用率的方法是 把需要挂载的目录软连接到
~/目录下ln -s /Volumes/eWORK ~/eWORKcolima start --mount ~/eWORK:w
After the initial run above, you can use colima start or use colima start -e to edit the configuration file. Run colima status at any time to check Colima’s status.
https://ddev.readthedocs.io/en/latest/users/install/docker-installation/#macos
to start Colima automatically on reboot
brew services start colimaBy default, Colima only mounts your home directory, so it’s easiest to use it in a subdirectory there. See the ~/.colima/default/colima.yaml.
在 Colima 中启用 Kubernetes + Docker runtime 时,docker 运行的是 Colima VM 内部的 Docker daemon,不是你的 macOS 系统 Docker。 要使 registry mirror 生效,必须正确配置 Colima VM 中的 Docker 守护进程。
# vi ~/.colima/default/colima.yaml
# replace `docker: {}` with
docker:
registry-mirrors:
- https://docker.m.daocloud.io
- https://dockerproxy.com
- https://docker.nju.edu.cn
- https://docker.mirrors.ustc.edu.cnto verify whether mirrors setting works
colima ssh -- cat /etc/docker/daemon.json; echo$ colima ssh
$ cat /etc/docker/daemon.json # 在这基础上追加 registry-mirrors, 然后写回
$ sudo sh -c 'cat > /etc/docker/daemon.json <<EOF
> {
"exec-opts": [
"native.cgroupdriver=cgroupfs"
],
"features": {
"buildkit": true,
"containerd-snapshotter": true
},
"proxies": {
"http-proxy": "http://192.168.5.2:3128",
"https-proxy": "http://192.168.5.2:3128",
"no-proxy": "localhost,127.0.0.0/24,10.192.0.0/16,192.168.0.0/16,kubernetes.docker.internal,wpad,172.16.0.0/12,172.17.0.0/16"
},
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.nju.edu.cn",
"https://docker.mirrors.ustc.edu.cn"
]
}
EOF'
$ sudo systemctl reload docker # apply
$ docker info # 确认
# 注意,如果要用就生效,还是需要修改 colima.yaml> colima ssh
$ top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
536 root 20 0 17656 8320 7424 R 100.0 0.2 20,31 systemd-logind在 x86_64 + vz backend 下,systemd-logind 是“已知问题源”
解决:
colima ssh
# 永久禁用
sudo systemctl disable systemd-logind.service --now
sudo systemctl mask systemd-logind.service
# 仅本次禁用
sudo systemctl disable systemd-logind --now
# 验证
systemctl status systemd-logind