SONIC添加国内源加速构建Dockerfile镜像

  1. SONIC是微软开源的关于白盒交换机的网络系统项目,详细说明信息可以查看SONIC官网。

  2. 由于SONIC是国外的开源项目,使用到Docker技术构建编译镜像sonic-slave和所有的应用程序都使用Docker构建,通过容器运行在设备上;由于国内编译整个SONIC工程时间过于长,记录一些可以加速的方式;

  3. 构建速度低最主要是因为在Dockerfile中的大量软件包的下载,而使用的又是国外的软件源,通过修改源达到加速的效果;

  4. 修改sonic-buildimage/sonic-slave/Dockerfile,注释掉原有的源,更换国内阿里云源;

#RUN sed -i '/deb http:\/\/mirrors.aliyun.com\/debian jessie-updates main/d' /etc/apt/sources.list

#RUN echo "deb http://debian-archive.trafficmanager.net/debian/ jessie main contrib non-free" >> /etc/apt/sources.list && \
#RUN echo "deb http://debian-archive.trafficmanager.net/debian/ jessie main contrib non-free" >> /etc/apt/sources.list && \
#        echo "deb-src http://debian-archive.trafficmanager.net/debian/ jessie main contrib non-free" >> /etc/apt/sources.list && \
#        echo "deb http://debian-archive.trafficmanager.net/debian-security/ jessie/updates main contrib non-free" >> /etc/apt/sources.list && \
#        echo "deb-src http://debian-archive.trafficmanager.net/debian-security/ jessie/updates main contrib non-free" >> /etc/apt/sources.list

# clean up source.list
RUN echo "" > /etc/apt/sources.list
# Add aliyun apt source
RUN echo "deb http://mirrors.aliyun.com/debian/ jessie main contrib non-free" >> /etc/apt/sources.list && \
        echo "deb-src http://mirrors.aliyun.com/debian/ jessie main contrib non-free" >> /etc/apt/sources.list && \
        echo "deb http://mirrors.aliyun.com/debian-security/ jessie/updates main contrib non-free" >> /etc/apt/sources.list && \
        echo "deb-src http://mirrors.aliyun.com/debian-security/ jessie/updates main contrib non-free" >> /etc/apt/sources.list && \
        # Add aliyun docer-ce source
        echo "deb https://mirrors.aliyun.com/docker-ce/linux/debian jessie stable " >> /etc/apt/sources.lista
# Add aliyun pip source
RUN mkdir ~/.pip && echo "[global]" >  ~/.pip/pip.conf && \
                    echo "index-url = http://mirrors.aliyun.com/pypi/simple" >>  ~/.pip/pip.conf && \
                    echo "trusted-host = mirrors.aliyun.com"  >>  ~/.pip/pip.conf && \
                    echo "timeout = 600 " >> ~/.pip/pip.conf
  1. 修改sonic-buildimage/sonic-slave-stretch/Dockerfile,同第四步;

  2. 其他的应用程序构建Dockerfile也可以作类似的处理,如果依靠安装apt install、pip install或者docker.download.com比较多的,则可以考虑修改;

你可能感兴趣的:(docker)