Files
wecom-ai-assistant/docs/docker-mirror.md
2026-02-05 16:36:32 +08:00

63 lines
2.0 KiB
Markdown
Raw Permalink 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.
# Docker 拉取失败:配置镜像加速
构建时若出现 `failed to fetch oauth token``dial tcp ... connectex` 等无法连接 `auth.docker.io` 的错误,多半是网络无法访问 Docker Hub。
## 本仓库已做的默认处理
- **admin** 与 **backend** 的 Dockerfile 已默认使用国内镜像源拉取基础镜像:`docker.mirrors.ustc.edu.cn/library/node:20-alpine``docker.mirrors.ustc.edu.cn/library/python:3.12-slim`。多数情况下可直接执行 `docker-compose up -d` 构建。
- 若你环境能直连 Docker Hub、希望用官方镜像可执行
```bash
docker-compose build --build-arg NODE_IMAGE=node:20-alpine --build-arg PYTHON_IMAGE=python:3.12-slim
docker-compose up -d
```
若仍报错(例如 USTC 镜像在你网络不可用),可再按下面方式配置 Docker daemon 的镜像加速。
## 方式一Docker Desktop推荐
1. 打开 **Docker Desktop** → **Settings**(设置)→ **Docker Engine**。
2. 在 JSON 里为 `"registry-mirrors"` 增加一个镜像地址,例如:
```json
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com"
]
}
```
3. 点击 **Apply & Restart**,等待重启完成。
4. 回到项目根目录重新执行:`docker-compose up -d`。
## 方式二Linux 直接改 daemon 配置
编辑 `/etc/docker/daemon.json`(没有则新建),加入:
```json
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com"
]
}
```
然后执行:
```bash
sudo systemctl daemon-reload
sudo systemctl restart docker
```
## 镜像源说明
- 上面为常见公共镜像,可用性以当前网络为准。
- 若使用阿里云 ECS可在容器镜像服务里申请**专属加速地址**,替换到 `registry-mirrors` 中,通常更稳定。
配置完成后再次运行:
```powershell
docker-compose up -d
```
若仍失败,可尝试开代理或换网络环境后再试。