linux 更改源为阿里云

/ docker / 没有评论 / 2109浏览

linux 更改源为阿里云

debian 7.x (wheezy)

编辑/etc/apt/sources.list文件(需要使用sudo), 在文件最前面添加以下条目(操作前请做好相应备份)

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 deb-src http://mirrors.aliyun.com/debian/ wheezy-proposed-updates main non-free contrib

debian 8.x (jessie)

编辑/etc/apt/sources.list文件(需要使用sudo), 在文件最前面添加以下条目(操作前请做好相应备份)

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 deb-src http://mirrors.aliyun.com/debian/ jessie-proposed-updates main non-free contrib

debian 9.x (stretch)

编辑/etc/apt/sources.list文件(需要使用sudo), 在文件最前面添加以下条目(操作前请做好相应备份)

## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
##     or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.debian.tmpl
###
# See http://www.debian.org/releases/stable/i386/release-notes/ch-upgrading.html
# for how to upgrade to newer versions of the distribution.
deb http://mirrors.aliyun.com/debian/ stretch main contrib non-free
deb http://mirrors.aliyun.com/debian/ stretch-updates main contrib non-free
deb http://mirrors.aliyun.com/debian/ stretch-proposed-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
## Major bug fix updates produced after the final release of the
## distribution.

deb-src http://mirrors.aliyun.com/debian/ stretch-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian/ stretch main contrib non-free
deb-src http://mirrors.aliyun.com/debian/ stretch-proposed-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main contrib non-free

deb http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib
## Uncomment the following two lines to add software from the 'backports'
## repository.
## 
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.

【教程】debian 换成阿里云的源

刚入 debian 的坑。。。目前是 debian9(stretch)+gnome3。刚开始装时候是 dvd 版安装,源都是 dvd 的本地目录。。。于是果断换源。。。打开阿里云镜像站:https://developer.aliyun.com/mirror/。找到”debian” 那一行,点帮助就可以看到源的用法了:

终端运行命令:

sudo gedit /etc/apt/sources.list

(如果没有 sudo 命令就用 su 命令)

用以下文字覆盖文件内容:

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

保存,在终端执行命令:

sudo apt-get update

解决There is no public key available错误

 W: There is no public key available for the following key IDs:7638D0442B90D010
 W: There is no public key available for the following key IDs:7638D0442B90D010
 W: There is no public key available for the following key IDs:9D6D8F6BC857C906

但是,老蒋这边更新源之后,执行升级命令还出现错误。下面的key等于上面的key.

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 7638D0442B90D010
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 7638D0442B90D010
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 9D6D8F6BC857C906

Docker ubuntu apt-get更换国内源解决Dockerfile构建速度过慢

在Dockerfile中添加如下两句代码:

RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list && apt-get clean

更新apt源的Dockerfile如下:

FROM ubuntu:latest
MAINTAINER kk "kk@qq.com"
RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list &&  apt-get clean && apt-get update

出现The following packages have unmet dependencies问题

这个自动修复依赖,有时候管用

If sudo apt-get install -f <package-name> doesn't work, try aptitude:
sudo apt-get install aptitude
sudo aptitude install <package-name>