compliance/test-docker-fix.sh
2025-08-27 16:55:39 +08:00

55 lines
1.4 KiB
Bash
Raw 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.

#!/bin/bash
# 测试Docker镜像拉取修复
echo "=== 测试Docker镜像拉取修复 ==="
# 测试基础镜像是否可用
echo "[测试 1] 检查python:3.11-slim镜像..."
if docker pull python:3.11-slim; then
echo "[✓] python:3.11-slim 镜像拉取成功"
else
echo "[✗] python:3.11-slim 镜像拉取失败"
fi
echo ""
# 测试原来的alpine镜像
echo "[测试 2] 检查python:3.11-alpine镜像..."
if timeout 30 docker pull python:3.11-alpine; then
echo "[✓] python:3.11-alpine 镜像拉取成功"
else
echo "[✗] python:3.11-alpine 镜像拉取失败或超时"
fi
echo ""
# 显示当前Docker配置
echo "[信息] 当前Docker镜像源配置:"
if [[ -f "/etc/docker/daemon.json" ]]; then
echo "系统配置:"
cat /etc/docker/daemon.json 2>/dev/null || echo "无法读取系统配置"
else
echo "未找到系统Docker配置文件"
fi
echo ""
# 建议解决方案
echo "=== 解决方案建议 ==="
echo "1. 已将Dockerfile从alpine改为slim基础镜像"
echo "2. 如果仍有问题请配置Docker镜像源:"
echo ""
echo " 创建/编辑 /etc/docker/daemon.json:"
echo ' {'
echo ' "registry-mirrors": ['
echo ' "https://docker.mirrors.ustc.edu.cn",'
echo ' "https://hub-mirror.c.163.com",'
echo ' "https://mirror.baidubce.com"'
echo ' ]'
echo ' }'
echo ""
echo "3. 重启Docker服务: sudo systemctl restart docker"
echo ""
echo "测试完成!"