Files
012-kaopeilian/知识库/配置Docker代理.md
111 998211c483 feat: 初始化考培练系统项目
- 从服务器拉取完整代码
- 按框架规范整理项目结构
- 配置 Drone CI 测试环境部署
- 包含后端(FastAPI)、前端(Vue3)、管理端

技术栈: Vue3 + TypeScript + FastAPI + MySQL
2026-01-24 19:33:28 +08:00

90 lines
2.2 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 代理配置指南
## 问题描述
Docker 无法连接到 Docker Hub 下载镜像,错误:
```
failed to fetch oauth token: Post "https://auth.docker.io/token": dial tcp 104.244.43.57:443: i/o timeout
```
## 解决方案
由于你使用代理上网http://127.0.0.1:1087需要配置 Docker 使用代理。
### 方法一Docker Desktop 图形界面配置(推荐)
1. **打开 Docker Desktop**
2. **点击右上角的齿轮图标(设置)**
3. **进入 Resources → Proxies**
4. **启用手动代理配置**
- Web Server (HTTP): `http://127.0.0.1:1087`
- Secure Web Server (HTTPS): `http://127.0.0.1:1087`
5. **点击 "Apply & Restart"**
### 方法二:命令行配置(已自动完成)
我已经为你配置了 `~/.docker/config.json`,内容如下:
```json
{
"proxies": {
"default": {
"httpProxy": "http://127.0.0.1:1087",
"httpsProxy": "http://127.0.0.1:1087",
"noProxy": "localhost,127.0.0.1"
}
}
}
```
### 方法三:使用阿里云镜像加速(备选方案)
如果代理配置仍然有问题,可以使用国内的 Docker 镜像加速:
1. 打开 Docker Desktop
2. 进入 Settings → Docker Engine
3. 在 JSON 配置中添加:
```json
{
"registry-mirrors": [
"https://kjphlxn2.mirror.aliyuncs.com"
]
}
```
4. 点击 "Apply & Restart"
## 验证配置
配置完成后,运行以下命令验证:
```bash
# 测试 Docker 连接
docker pull hello-world
# 如果成功,继续构建项目
cd /Users/nongjun/Desktop/Ai公司/本地开发与测试/kaopeilian-backend
docker-compose -f docker-compose.dev.yml build backend
```
## 常见问题
### Q: 为什么需要配置代理?
A: 你的网络通过代理访问外网Docker 也需要通过代理才能连接到 Docker Hub。
### Q: 哪种方法最可靠?
A: 推荐使用 Docker Desktop 图形界面配置(方法一),这会同时配置客户端和守护进程。
### Q: 配置后还是不行怎么办?
A:
1. 确认代理服务http://127.0.0.1:1087正在运行
2. 尝试使用阿里云镜像加速(方法三)
3. 重启 Docker Desktop
## 下一步
配置完成后,请运行启动脚本:
```bash
cd /Users/nongjun/Desktop/Ai公司/本地开发与测试
./启动资料预览功能.sh
```