Docker Debian 鏡像源替換
因多數默認的 Docker 鏡像為國外的,而采用的鏡像源也是國外的,故訪問很慢,所以我們需要替換為國內的(比如阿里雲或163等)。
注意: 不同版本的 Debian 鏡像源地址不一樣
Debian 7.x (wheezy)
# 更新apt-get源
RUN echo \
deb http://mirrors.aliyun.com/debian/ wheezy main non-free contrib\
deb http://mirrors.aliyun.com/debian/ wheezy-proposed-updates main non-free contrib\
deb-src http://mirrors.aliyun.com/debian/ wheezy main non-free contrib\
> /etc/apt/sources.list
Debian 8.x (jessie)
# 更新apt-get源
RUN echo \
deb http://mirrors.aliyun.com/debian/ jessie main non-free contrib\
deb http://mirrors.aliyun.com/debian/ jessie-proposed-updates main non-free contrib\
deb-src http://mirrors.aliyun.com/debian/ jessie main non-free contrib\
> /etc/apt/sources.list
Debian 9.x (stretch)
# 更新apt-get源
RUN echo \
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib\
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib\
deb http://mirrors.aliyun.com/debian-security stretch/updates main\
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main\
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib\
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib\
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib\
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib\
> /etc/apt/sources.list
Laradock 鏡像構建失敗
因為默認用的是國外 Debian 鏡像源,故在執行
apt-get
等命令拉取軟件包時會失敗,我們需手動在對於的Dockerfile
中添加一個 RUN 指令來替換掉默認的鏡像源
以下僅為示例:
需根據自己當前 Laradock 版本查看引用的系統鏡像及其版本注意不同,其他系統(eg: CentOS)請對症下葯。
# 更新apt-get源
RUN echo \
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib\
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib\
deb http://mirrors.aliyun.com/debian-security stretch/updates main\
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main\
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib\
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib\
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib\
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib\
> /etc/apt/sources.list
感謝您的閱讀,覺得內容不錯,點個贊吧 😆
原文地址: https://shockerli.net/post/replace-docker-laradock-debian-mirrors/