Docker容器构建时安装containerd.io_1.6.9-1_amd64.deb出错求助
问题分析与解决
问题根源
你的基础镜像python:3.6.2基于Debian 9(Stretch),但你手动下载的containerd.io_1.6.9-1_amd64.deb是为**Debian 10(Buster)**编译的包,两者依赖的系统库版本不兼容(比如包要求libc6 >= 2.28,但Stretch的libc6版本仅为2.24),导致安装失败。此外,原Dockerfile中错误添加了Ubuntu Focal的Docker源,与Debian系统不匹配,也会引发依赖问题。
修复方案
不要手动下载跨版本的deb包,直接通过Docker官方源安装适配当前系统的containerd.io和docker-ce,让apt自动处理依赖。修正后的Dockerfile如下:
FROM python:3.6.2 RUN apt-get update && apt-get install -y make RUN pip install -U pip setuptools wheel RUN python -m pip install -r model-requirements.txt --python-version 3.6 --no-deps --target python6_pakages # Installing docker-ce(修正后的安装流程) RUN apt-get update && apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ software-properties-common \ gnupg # 添加Docker官方GPG密钥 RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - # 添加对应Debian Stretch的Docker源 RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable" # 更新源并安装docker-ce(自动安装兼容的containerd.io) RUN apt-get update && apt-get install -y docker-ce # 安装其他工具 RUN apt-get install -y cron vim iputils-ping curl g++ unixodbc-dev supervisor
关键修正点
- 替换Docker源为Debian Stretch对应的版本,移除了错误的Ubuntu Focal源
- 移除手动下载containerd.io deb包的步骤,让apt自动从官方源拉取适配当前系统的版本,自动解决依赖冲突
- 合并多个零散的
RUN指令,减少镜像层数,同时避免重复apt-get update导致的缓存失效问题
内容的提问来源于stack exchange,提问作者Kia Lia
相关产品推荐
相关产品推荐

