From f856b00eed3377584ead7e38fb4e9015fed5da80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A5=AD=E5=9B=A2?= Date: Sat, 14 Mar 2026 22:56:10 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=E5=9B=BD=E5=86=85=20?= =?UTF-8?q?Docker=20=E9=95=9C=E5=83=8F=E5=8A=A0=E9=80=9F=E5=99=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - README.md: 新增国内网络问题解决方案 - Docker 镜像加速器配置 - 使用国内 Node.js 镜像 - 手动拉取镜像方法 - Dockerfile: 注释说明国内镜像源用法 --- Dockerfile | 2 ++ README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8cc7d8b..ea458ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# 使用国内镜像源(可选,如果 Docker 加速器无效) +# FROM registry.cn-hangzhou.aliyuncs.com/library/node:18-alpine FROM node:18-alpine WORKDIR /app diff --git a/README.md b/README.md index 010b51d..50e4043 100644 --- a/README.md +++ b/README.md @@ -241,25 +241,82 @@ docker run -d \ #### 🔧 Docker 故障排查 +**查看容器日志** ```bash -# 查看容器日志 docker logs --tail 100 qiniu-bot +``` -# 进入容器调试 +**进入容器调试** +```bash docker exec -it qiniu-bot /bin/sh +``` -# 检查容器健康状态 +**检查容器健康状态** +```bash docker inspect --format='{{.State.Health.Status}}' qiniu-bot +``` -# 查看资源使用 +**查看资源使用** +```bash docker stats qiniu-bot +``` -# 清理未使用的镜像 +**清理未使用的镜像** +```bash 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 部署检查清单 - [ ] `.env` 文件已配置(包含飞书和七牛云密钥)