文章出處

一般對于安裝軟件加速時,我們大多數會選擇阿里云,而對于aspnetcore2.0這個進項來說,由于使用的是Debian操作系統,所有我們要找到它對應的mirror列表,下面是我整理的一個sources.list加速列表,我們把它放在和Dockerfile相同的位置,在Dockerfile生成鏡像時把它復制到里面去,替換之前的apt-update地址源即可。

source.list內容

deb http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free

然后我們對Dockerfile進行一些修改,在生成鏡像時把它復制到鏡像里

FROM microsoft/aspnetcore:2.0
ARG source
COPY sources.list /etc/apt/sources.list
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
RUN apt-get update && apt-get -y install libgdiplus
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "SMS.dll"]

然后我們再去生成鏡像,就會非常非常快了!

當然,你也可以不添加這個文件,而直接把文本覆蓋到原來的source.list文件里

FROM microsoft/aspnetcore:2.0
ARG source

RUN echo "deb http://mirrors.aliyun.com/debian wheezy main contrib non-free \
deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free \
deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free \
deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free \
deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free \
deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free" > /etc/apt/sources.list

RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
RUN apt-get update &&  apt-get install libgdiplus -y
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Pilipa.SMS.dll"]

上面的做法也是完全沒有問題的!

你要是在阿里云服務器上,那就是內網對內網,更快!


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()