当前位置: 首页 > news >正文

在mac中安装Colima使用docker(替代Docker Desktop)

目录

推荐方案:Colima + Docker CLI(原生 ARM 支持)

步骤 1: 安装必需工具

步骤 2: 启动 Colima (优化 ARM 虚拟机)

步骤 3: 绑定 Docker CLI 到 Colima

步骤 4: 验证 Docker 运行

方案对比与注意事项

常见陷阱

卸载残留配置(可选)


推荐方案:Colima + Docker CLI(原生 ARM 支持)

步骤 1: 安装必需工具
# 安装 Homebrew(若尚未安装)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 安装 Colima 和 Docker CLI(原生支持 Apple Silicon)
brew install colima docker docker-compose
步骤 2: 启动 Colima (优化 ARM 虚拟机)
# 为 Apple Silicon 启动轻量级 ARM 虚拟机(默认使用 containerd 运行时)
colima start --arch aarch64 --runtime containerd \
  --cpu 4 --memory 8 --disk 20 # 根据需求调整 CPU/内存/磁盘
  • --arch aarch64: 明确指定 ARM 架构,适配 Apple Silicon。
  • -runtime containerd: 使用更轻量的 containerd(或手动替换为 docker 运行时)。
步骤 3: 绑定 Docker CLI 到 Colima
docker context use colima
步骤 4: 验证 Docker 运行
# 运行 ARM 架构的测试容器(自动拉取适配镜像)
docker run --rm --platform linux/arm64 hello-world
  • --platform linux/arm64: 强制使用 ARM 架构容器(避免 x86 镜像兼容问题)。

后续每次启动docker之前,需要先启动Colima

启动Colima命令

Colima start

停止Colima命令

stop Colima


方案对比与注意事项

工具优势M1/M2 注意事项
Colima✅ 原生支持 Apple Silicon<br/>✅ 自动配置 DNS 和挂载路径如遇镜像兼容问题,运行命令添加 --platform linux/arm64 指定架构
Minikube❌ 复杂且主要用于 Kubernetes需通过 minikube start --driver=docker --container-runtime=containerd 手动适配
常见陷阱
  1. 镜像架构不匹配问题
    默认镜像可能为 x86_64,需显式选择 linux/arm64 架构:

    docker pull --platform linux/arm64 nginx:alpine
    # 或直接运行时指定
    docker run --platform linux/arm64 nginx:alpine
    
  2. 挂载目录权限修复
    若遇到文件挂载权限问题,通过 colima 调整挂载的 UID/GID:

    colima stop
    colima start --mount-type=9p --mount-ownership [$UID]:$(id -g)
    

卸载残留配置(可选)
colima delete -f        # 删除 Colima 虚拟机
docker context rm colima # 删除 Docker 上下文
brew uninstall colima   # 卸载 Colima

文章转载自:
http://basalt.hyyxsc.cn
http://chloroprene.hyyxsc.cn
http://carpology.hyyxsc.cn
http://christianism.hyyxsc.cn
http://archetype.hyyxsc.cn
http://analgesia.hyyxsc.cn
http://androdioecism.hyyxsc.cn
http://ceresin.hyyxsc.cn
http://beneficence.hyyxsc.cn
http://bugs.hyyxsc.cn
http://bowdlerize.hyyxsc.cn
http://cashmere.hyyxsc.cn
http://agalloch.hyyxsc.cn
http://brix.hyyxsc.cn
http://annum.hyyxsc.cn
http://aduncate.hyyxsc.cn
http://boycott.hyyxsc.cn
http://aarp.hyyxsc.cn
http://aerospace.hyyxsc.cn
http://absently.hyyxsc.cn
http://celiac.hyyxsc.cn
http://acetoacetyl.hyyxsc.cn
http://agalloch.hyyxsc.cn
http://agamid.hyyxsc.cn
http://adult.hyyxsc.cn
http://anethole.hyyxsc.cn
http://anthologist.hyyxsc.cn
http://audit.hyyxsc.cn
http://astrographic.hyyxsc.cn
http://bleachers.hyyxsc.cn
http://www.dtcms.com/a/14003.html

相关文章:

  • MapReduce到底是个啥?
  • 无人机 ,遥控器与接收机之前的通信
  • Python 调用 Azure OpenAI API
  • 浅谈Java Spring Boot 框架分析和理解
  • 掌握正则表达式_模式匹配的艺术
  • 【实测】用全志A733平板搭建一个端侧Deepseek算力平台
  • DeepSeek 助力 Vue 开发:打造丝滑的步骤条
  • 渗透利器:YAKIT 工具-基础实战教程.
  • TCP/IP 协议
  • #渗透测试#批量漏洞挖掘#29网课交单平台 SQL注入
  • Unity进阶教程AOI算法原理详解
  • 计算机视觉的研究方向、发展历程、发展前景介绍
  • 深入理解Java对接DeepSeek
  • 【Java 面试 八股文】Redis篇
  • 深入HBase——引入
  • Unity开发播放视频
  • 数据治理双证通关经验分享 | CDGA/CDGP备考全指南
  • 深入了解 MySQL:从基础到高级特性
  • 嵌入式WebRTC压缩至670K,目标将so动态库压缩至500K,.a静态库还可以更小
  • Unity使用iTextSharp导出PDF-04图形
  • 5、pod 详解 (kubernetes)
  • 【C++八股】智能指针
  • 372_C++_当有多个通道,开启不同告警的同一种的开关时,限制该开关的打开数量(比如视频上传开关)
  • Spring Boot 中的事务管理:默认配置、失效场景及集中配置
  • 北斗导航 | 基于多假设解分离(MHSS)模型的双星故障监测算法(MATLAB代码实现——ARAIM)
  • 【prompt示例】智能客服+智能质检业务模版
  • vue组件中各种类型之间的传值
  • Spring Boot 配置 Mybatis 读写分离
  • mapbox进阶,添加绘图扩展插件,绘制任意方向矩形
  • 【LLM】13:大模型算法面试题库