今天遇见在docker,新建一个容器遇见了这样一个问题。下载nginx 的时候,
root@114e9c6168c0:/# apt-get install -y nginx
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package nginx

问题:为什么会 Unable to locate package nginx

回答:apt-get 源里面没有nginx 包

解决办法 1、apt-get update 更新本地源

解决办法 2、更新源

1、原文件重命名备份
sudo mv /etc/apt/sources.list /etc/apt/source.list.bak 
2、编辑源列表文件
sudo vim /etc/apt/sources.list
3、复制

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

4、更新
sudo apt-get update
sudo apt-get upgrade

解决!!!!

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐