在Ubuntu中利用apt-get安装软件时,由于网络问题,我们经常将apt-get源改为国内的源镜像,在构建docker容器时,安装软件怎么改变将apt-get源改为国内镜像呢?
只需要在执行安装命令前修改源即可
#apt-get源 使用163的源
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-proposed-updates main non-free contrib" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list
然后再执行安装命令即可,如:
# -qq 忽略日志 只在发生错误时打印
RUN apt-get -qq update && apt-get install -qq sudo
所有评论(0)