howto:在構建基於debian的docker基礎鏡像時,更換國內包源


debian經常被用作構建應用鏡像的基礎鏡像,如微軟在構建linux下的dotnetcore基礎鏡像時,提供了基於debian 8(jessie)和debian 9(stretch)的鏡像。

由於這些鏡像采用的官方包源在國內的訪問速度問題,我們在基於aspnet或者dotnet構建鏡像時,通常需要將其替換為國內的包源,從而提升鏡像構建的速度和成功率。

更改包源的Dockerfile指令如下:

# 更新阿里雲的wheezy版本包源
RUN echo "deb http://mirrors.aliyun.com/debian wheezy main contrib non-free" > /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free" >> /etc/apt/sources.list  && \
    echo "deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free" >> /etc/apt/sources.list

上述配置針對采用阿里雲提供的debian 7(wheezy)的鏡像源,如果采用jessie或者stretch的系統,可以替換wheezy關鍵詞即可。
如果采用網易提供的鏡像源,將上述地址替換為:
    http://mirrors.163.com/debian/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM