文章出處
文章列表
一般對于安裝軟件加速時,我們大多數會選擇阿里云,而對于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"]
上面的做法也是完全沒有問題的!
你要是在阿里云服務器上,那就是內網對內網,更快!
文章列表
全站熱搜