黄贵川 發表於 2019-5-9 22:23:00

替换 Docker 或 Laradock 中 Debian 系统镜像源解决软件安装问题

<h2 id="docker-debian-镜像源替换">Docker Debian 镜像源替换</h2>
<p>因多数默认的 Docker 镜像为国外的,而采用的镜像源也是国外的,故访问很慢,所以我们需要替换为国内的(比如阿里云或163等)。</p>
<ul>
<li>163 - Debian</li>
<li>Aliyun - Debian</li>
</ul>
<blockquote>
<p>注意: 不同版本的 Debian 镜像源地址不一样</p>
</blockquote>
<h3 id="debian-7x-wheezy">Debian 7.x (wheezy)</h3>
<pre><code class="language-sh"># 更新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\
    &gt; /etc/apt/sources.list
</code></pre>
<h3 id="debian-8x-jessie">Debian 8.x (jessie)</h3>
<pre><code class="language-sh"># 更新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\
    &gt; /etc/apt/sources.list
</code></pre>
<h3 id="debian-9x-stretch">Debian 9.x (stretch)</h3>
<pre><code class="language-sh"># 更新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\
    &gt; /etc/apt/sources.list
</code></pre>
<h2 id="laradock-镜像构建失败">Laradock 镜像构建失败</h2>
<blockquote>
<p>因为默认用的是国外 Debian 镜像源,故在执行 <code>apt-get</code> 等命令拉取软件包时会失败,我们需手动在对于的 <code>Dockerfile</code> 中添加一个 RUN 指令来替换掉默认的镜像源</p>
</blockquote>
<p><strong>以下仅为示例</strong>:</p>
<blockquote>
<p>需根据自己当前 Laradock 版本查看引用的系统镜像及其版本注意不同,其他系统(eg: CentOS)请对症下药。</p>
</blockquote>
<pre><code class="language-sh"># 更新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\
    &gt; /etc/apt/sources.list
</code></pre>
<hr>
<p>感谢您的阅读,觉得内容不错,点个赞吧 😆<br>
原文地址: https://shockerli.net/post/replace-docker-laradock-debian-mirrors/</p><br><br>
来源:https://www.cnblogs.com/shockerli/p/replace-docker-laradock-debian-mirrors.html
頁: [1]
查看完整版本: 替换 Docker 或 Laradock 中 Debian 系统镜像源解决软件安装问题