Files
docker_practice/03_install/3.7_mac.md
T
yeasy 1fc64ab875 Refresh install guidance
# Conflicts:
#	03_install/3.1_ubuntu.md
#	03_install/3.2_debian.md
#	03_install/3.3_fedora.md
#	03_install/3.9_mirror.md
2026-04-22 08:24:38 -07:00

76 lines
3.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 3.7 macOS
### Mac 用户的特殊考虑
macOS 上没有原生 Linux 内核Docker 需要运行在一个轻量级虚拟机中Docker Desktop 完全封装了这个复杂性 Mac 用户可以像 Linux 用户一样使用 Docker但有几点需要特别了解
**性能特性**
- Apple SiliconM 系列芯片 Intel Mac 的性能更好且拥有原生支持
- 文件 I/O 性能macOS 与容器之间的卷挂载性能不如 Linux这是虚拟化的代价
- 内存使用Docker Desktop 本身会消耗一定内存用于虚拟机管理
**许可考虑**
- 小型企业少于 250 名员工且年收入低于 1000 万美元)、个人使用教育和非商业开源项目可免费使用
- 超出上述范围的商业用途需要付费订阅
### 3.7.1 系统要求
[Docker Desktop for Mac](https://docs.docker.com/desktop/setup/install/mac-install/) 支持当前版本及前两个主要版本的 macOS,并且至少需要 4 GB 内存。对于 Apple Silicon 机型,若需要兼容部分 Intel 命令行工具,官方建议安装 Rosetta 2。
### 3.7.2 安装
> [!WARNING]
> **商业许可限制**Docker Desktop 对小型企业少于 250 名员工且年收入低于 1000 万美元)、个人使用教育和非商业开源项目仍然免费超出上述范围的商业用途需要付费订阅企业用户请注意合规风险
Docker Desktop Mac 用户提供了标准的图形化安装体验官方当前主要提供 DMG 交互安装和命令行/企业部署安装这里先介绍最常见的 DMG 安装方式
#### 手动下载安装
如果需要手动下载可直接使用 [Docker Desktop for Mac Intel ](https://desktop.docker.com/mac/main/amd64/Docker.dmg) 安装包。
> 如果你的电脑搭载的是 Apple Silicon 芯片`arm64` 架构),请使用 [Docker Desktop for Mac Apple Silicon ](https://desktop.docker.com/mac/main/arm64/Docker.dmg)。
如同 macOS 其它软件一样安装也非常简单双击下载的 `.dmg` 文件然后将那只叫 [Moby](https://www.docker.com/blog/call-me-moby-dock/) 的鲸鱼图标拖拽到 `Application` 文件夹即可 (其间需要输入用户密码)。
![](../_images/install-mac-dmg.jpg)
### 3.7.3 运行
从应用中找到 Docker 图标并点击运行
![](../_images/install-mac-apps.jpg)
运行之后会在右上角菜单栏看到多了一个鲸鱼图标这个图标表明了 Docker 的运行状态
![](../_images/install-mac-menubar.png)
每次点击鲸鱼图标会弹出操作菜单
![](../_images/install-mac-menu.png)
之后你可以在终端通过命令检查安装后的 Docker 版本
```bash
$ docker version
$ docker info
```
如果 `docker version` `docker info` 都能正常返回信息就可以尝试运行一个 [Nginx 服务器](https://hub.docker.com/_/nginx/)
```bash
$ docker run -d -p 80:80 --name webserver nginx
```
服务运行后可以访问 [http://localhost](http://localhost)。如果看到了 `Welcome to nginx!`,就说明 Docker Desktop for Mac 安装成功了。
![](../_images/install-mac-example-nginx.png)
要停止并删除 Nginx 容器执行下面的命令
```bash
$ docker stop webserver
$ docker rm webserver
```
### 3.7.4 镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker [国内镜像加速](3.9_mirror.md)