基于python:3.10-slim-buster构建Docker镜像时apt-get update报403错误
解决Docker构建时Debian Buster源403错误的方法
问题原因
Debian Buster(版本10)已结束常规支持周期,原官方源地址deb.debian.org不再提供该版本的软件包服务,导致请求返回403 Forbidden,同时因源地址变更出现签名验证失败提示。
修复步骤
修改Dockerfile,在执行apt-get update前将APT源替换为Debian归档服务器地址:
FROM python:3.10-slim-buster # Set uid and gid for sally ARG sally_uid=2002 ARG sally_gid=2002 # Add user and group entries RUN addgroup -gid $sally_gid sally && adduser --uid $sally_uid --ingroup sally --system sally # 替换APT源为Debian归档服务器 RUN echo "deb http://archive.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list && \ echo "deb http://archive.debian.org/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list # 执行更新与升级 RUN apt-get update && apt-get upgrade -y && apt-get -y dist-upgrade ...... ...... ......
补充处理
- 若仍存在签名验证问题,可临时在
apt-get update后添加--allow-unauthenticated参数(优先确保源地址正确,此为应急方案):RUN apt-get update --allow-unauthenticated && apt-get upgrade -y && apt-get -y dist-upgrade - 强制清理构建缓存后重新执行构建:
docker build --no-cache -t supervised:1.0 .
内容的提问来源于stack exchange,提问作者Amit
相关产品推荐
相关产品推荐

