使用 colima 替代 limactl

colima

limactl 使用还是比较麻烦,推各种搜索,推荐使用 colima。

$ rm -rf ~/.docker
$ rm -rf ~/.lima

$ brew install colima
$ brew install docker docker-compose

启动

colima volumes 文件写入权限问题,参考:

  • https://github.com/langgenius/dify/issues/4126
  • https://github.com/abiosoft/colima/issues/1067#issuecomment-2231475199

所以,需要指定一下 vm-type 和 mount-type

# 默认是 sshfs,会导致 volumes 的权限有问题
$ colima start --mount-type=virtiofs

# 权限写入测试
$ mkdir test
$ docker run -v ./test:/var/lib/postgresql/data -e POSTGRES_PASSWORD=password postgres:15-alpine

镜像加速

这也是我替换 limactl 到 colima 的原因,因为国内环境问题,需要配置相关镜像地址,所以:

$ vi ~/.colima/default/colima.yaml

修改 docker 配置为以下内容:

docker:
  # insecure-registries:
  #   - yum.tbsite.net
  registry-mirrors:
    # - http://yum.tbsite.net/mirrors/
    - https://docker.m.daocloud.io
    - https://dockercf.jsdelivr.fyi
    - https://docker.jsdelivr.fyi
    - https://dockertest.jsdelivr.fyi
    - https://dytt.online
    - https://docker.1ms.run
    - https://func.ink
    - https://docker.zhai.cm
    - https://docker.xuanyuan.me
    - https://docker.hlmirror.com
    - https://doublezonline.cloud
    - https://dislabaiot.xyz/
    - https://hub.mirrorify.net
    - https://docker-pull.ygxz.in

# https://blog.eimoon.com/p/docker-registry-mirror-2025/
# https://www.xuxlc.cn/article/details-40.html

x86 profile

# 启动 x86 架构 colima
$ colima start x86 --arch x86_64 --vm-type=vz --mount-type=virtiofs

$ colima stop x86

docker mananger

$ npm i -g dockly

$ dockly -s ~/.colima/x86/docker.sock
$ dockly -s ~/.colima/default/docker.sock

Limits

  • heredocs 不支持
    • https://zhoukekestar.github.io/notes/2024/10/18/docker-speedup.html
    • https://stackoverflow.com/questions/77191591/dockerfile-run-command-cannot-use-heredoc-with-build-args
    • https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/