docs: 添加国内 Docker 镜像加速器配置说明

- README.md: 新增国内网络问题解决方案
  - Docker 镜像加速器配置
  - 使用国内 Node.js 镜像
  - 手动拉取镜像方法
- Dockerfile: 注释说明国内镜像源用法
This commit is contained in:
饭团
2026-03-14 22:56:10 +08:00
parent f7e71a9bb0
commit f856b00eed
2 changed files with 64 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
# 使用国内镜像源(可选,如果 Docker 加速器无效)
# FROM registry.cn-hangzhou.aliyuncs.com/library/node:18-alpine
FROM node:18-alpine FROM node:18-alpine
WORKDIR /app WORKDIR /app

View File

@@ -241,25 +241,82 @@ docker run -d \
#### 🔧 Docker 故障排查 #### 🔧 Docker 故障排查
**查看容器日志**
```bash ```bash
# 查看容器日志
docker logs --tail 100 qiniu-bot docker logs --tail 100 qiniu-bot
```
# 进入容器调试 **进入容器调试**
```bash
docker exec -it qiniu-bot /bin/sh docker exec -it qiniu-bot /bin/sh
```
# 检查容器健康状态 **检查容器健康状态**
```bash
docker inspect --format='{{.State.Health.Status}}' qiniu-bot docker inspect --format='{{.State.Health.Status}}' qiniu-bot
```
# 查看资源使用 **查看资源使用**
```bash
docker stats qiniu-bot docker stats qiniu-bot
```
# 清理未使用的镜像 **清理未使用的镜像**
```bash
docker image prune -a docker image prune -a
``` ```
--- ---
#### 🌏 国内网络问题(镜像拉取超时)
**问题:** `failed to solve: DeadlineExceeded: node:18-alpine: failed to resolve source metadata`
**解决方案 1配置 Docker 镜像加速器**
```bash
# 配置镜像加速器
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
EOF
# 重启 Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
# 验证
docker info | grep "Registry Mirrors"
```
**解决方案 2使用国内 Node.js 镜像**
修改 `Dockerfile` 第一行:
```dockerfile
# 使用阿里云镜像
FROM registry.cn-hangzhou.aliyuncs.com/library/node:18-alpine
```
**解决方案 3手动拉取镜像**
```bash
# 先手动拉取(使用加速器)
docker pull registry.cn-hangzhou.aliyuncs.com/library/node:18-alpine
# 打标签
docker tag registry.cn-hangzhou.aliyuncs.com/library/node:18-alpine node:18-alpine
# 重新构建
docker-compose up -d --build
```
---
#### 📋 Docker 部署检查清单 #### 📋 Docker 部署检查清单
- [ ] `.env` 文件已配置(包含飞书和七牛云密钥) - [ ] `.env` 文件已配置(包含飞书和七牛云密钥)