【docker】build中的apt失败

问题描述

在使用docker打包的时候,今天突然报错,卡在apt-get update了
【docker】build中的apt失败_第1张图片
然后就是各种重启,无果。
然后查了下,需要在RUN apt-get update之前添加

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo 'deb http://mirrors.163.com/debian/ jessie main non-free contrib' > /etc/apt/sources.list && \
echo 'deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib' >> /etc/apt/sources.list

果然,解决的这个包下载的问题,但是新问题来。
包的依赖不对了。。。
【docker】build中的apt失败_第2张图片
有报错就好弄,查下报错,其实就是依赖不匹配,还是源的问题,然后各种搜,搜到一个完美匹配的方案

http://www.3624091.com/blogs/detail/60

【docker】build中的apt失败_第3张图片
完整dockerfile修改如下

FROM microsoft/dotnet:2.1-aspnetcore-runtime
#安装apt-get 安装 libc6-dev , libgdiplus  用于支持system.drawing 组件绘制,默认ubuntu命令
#RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
# 配置apt的资源,采用阿里云资源仓库 必须是debian 10 buster版本
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
   echo "deb http://mirrors.aliyun.com/debian/ buster main non-free contrib" >/etc/apt/sources.list && \
   echo "deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib" >>/etc/apt/sources.list && \
   echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >>/etc/apt/sources.list && \
   echo "deb-src http://mirrors.aliyun.com/debian-security buster/updates main" >>/etc/apt/sources.list && \
   echo "deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >>/etc/apt/sources.list && \
   echo "deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >>/etc/apt/sources.list && \
   echo "deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >>/etc/apt/sources.list && \
   echo "deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >>/etc/apt/sources.list
RUN  apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
COPY . /publish
WORKDIR /publish

EXPOSE 8044

ENV LANG C.UTF-8

ENTRYPOINT ["dotnet", "Tigzx.Service.Account.dll"]

然后就成功了,我草。。。
在这里插入图片描述

你可能感兴趣的:(docker,docker,apt)