因多數默認的 Docker 鏡像爲國外的,而採用的鏡像源也是國外的,故訪問很慢,因此咱們須要替換爲國內的(好比阿里雲或163等)。html
注意: 不一樣版本的 Debian 鏡像源地址不同
# 更新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
# 更新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
# 更新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
由於默認用的是國外 Debian 鏡像源,故在執行apt-get
等命令拉取軟件包時會失敗,咱們需手動在對於的Dockerfile
中添加一個 RUN 指令來替換掉默認的鏡像源
如下僅爲示例:docker
需根據本身當前 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/segmentfault