在容器里执行apt-get命令时候,报如下错误,替换国内的镜像源即可。
apt-get install net-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package net-tools
root@cloud-front-769f97f7b8-mvzjp:/# apt-get update
Ign http://security.debian.org wheezy/updates Release.gpg
Ign http://security.debian.org wheezy/updates Release
Get:1 http://nginx.org wheezy Release.gpg [287 B]
Get:2 http://nginx.org wheezy Release [2343 B]
Ign http://nginx.org wheezy Release
Get:3 http://nginx.org wheezy/nginx amd64 Packages [31.9 kB]
Err http://security.debian.org wheezy/updates/main amd64 Packages
Err http://security.debian.org wheezy/updates/main amd64 Packages
Err http://security.debian.org wheezy/updates/main amd64 Packages
Err http://security.debian.org wheezy/updates/main amd64 Packages
Err http://security.debian.org wheezy/updates/main amd64 Packages
404 Not Found [IP: 151.101.128.204 80]
Ign http://http.debian.net wheezy Release.gpg
Ign http://http.debian.net wheezy-updates Release.gpg
Ign http://http.debian.net wheezy Release
Ign http://http.debian.net wheezy-updates Release
Err http://http.debian.net wheezy/main amd64 Packages
Err http://http.debian.net wheezy-updates/main amd64 Packages
Err http://http.debian.net wheezy/main amd64 Packages
Err http://http.debian.net wheezy-updates/main amd64 Packages
Err http://http.debian.net wheezy/main amd64 Packages
Err http://http.debian.net wheezy-updates/main amd64 Packages
Err http://http.debian.net wheezy/main amd64 Packages
Err http://http.debian.net wheezy-updates/main amd64 Packages
Err http://http.debian.net wheezy/main amd64 Packages
404 Not Found
Err http://http.debian.net wheezy-updates/main amd64 Packages
404 Not Found
Fetched 34.6 kB in 12s (2774 B/s)
W: GPG error: http://nginx.org wheezy
使用163的源
# 更新apt-get源
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
使用阿里云的源
# 更新apt-get源
mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
echo "deb http://mirrors.aliyun.com/debian stretch main contrib non-free" >/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free" >>/etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free" >>/etc/apt/sources.list && \
echo "deb-src http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free" >>/etc/apt/sources.list
阿里云的源的配置似乎有点旧了,可参考官网提供的方式更新一下: https://developer.aliyun.com/mirror/debian