Files
dysync/docs/构建问题排查.md
yuming ad97fd3da5 整理仓库:扩展 gitignore、归档文档、清理冗余 Dockerfile
- .gitignore 新增忽略 .idea/、videos/、*.tar.gz、*.csproj.user、db 运行时文件
- 根目录 15 个中文运维 md 归档到 docs/
- 删除无部署脚本引用的 Dockerfile 与 Dockerfile-arm(保留 Dockerfile.prod)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 21:28:41 +08:00

80 lines
1.8 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 构建问题排查
## 问题:网络超时无法拉取镜像
### 解决方案
1. **已配置镜像加速器** ✅
- 已添加国内镜像源到 `~/.docker/daemon.json`
- 镜像源包括:中科大、网易、百度云
2. **重启 Docker Desktop**
- 点击状态栏的 Docker 图标
- 选择 "Quit Docker Desktop"
- 重新启动 Docker Desktop
- 等待 Docker 完全启动(状态栏图标不再闪烁)
3. **验证镜像加速器是否生效**
```bash
docker info | grep -A 10 "Registry Mirrors"
```
应该看到配置的镜像源列表。
4. **重新构建镜像**
```bash
cd /Users/gaotu/WebstormProjects/dysync.net
docker build -f Dockerfile.prod -t dysync.net:latest .
```
### 如果仍然失败
**方案 A:使用代理(如果有)**
在 Docker Desktop 中配置代理:
- Settings → Resources → Proxies
- 配置 HTTP/HTTPS 代理
**方案 B:手动拉取镜像**
```bash
# 手动拉取所需的基础镜像
docker pull node:18-alpine
docker pull mcr.microsoft.com/dotnet/sdk:6.0
docker pull mcr.microsoft.com/dotnet/aspnet:6.0
# 然后再构建
docker build -f Dockerfile.prod -t dysync.net:latest .
```
**方案 C:使用阿里云镜像(推荐)**
如果你有阿里云账号,可以配置阿里云容器镜像服务的加速器:
1. 登录阿里云容器镜像服务:https://cr.console.aliyun.com/
2. 获取你的专属加速地址(格式:`https://xxxxx.mirror.aliyuncs.com`)
3. 更新 `~/.docker/daemon.json`:
```json
{
"registry-mirrors": [
"https://你的专属地址.mirror.aliyuncs.com"
]
}
```
4. 重启 Docker Desktop
### 检查网络连接
```bash
# 测试 Docker Hub 连接
curl -I https://registry-1.docker.io/v2/
# 测试镜像源连接
curl -I https://docker.mirrors.ustc.edu.cn/v2/
```