先上结论
m1芯片的mac应使用以下源(适用20.04版本):
deb http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
再讲原因
因为架构的原因,在x86和arm下ubuntu所使用的源是不同的,两者无法混用
在Intel或Amd处理器下,通过Docker安装的ubuntu自带的源为
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
而在m1芯片下则为
deb http://ports.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
区别就在于前面的archive和ports
以阿里云的镜像源为例,在阿里云镜像的官方网站上为ubuntu 20.04提供的源为
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
不难看出,只需将域名后的ubuntu改为ubuntu-ports即可。
此外,再提供一个可以直接在命令行中使用的换源命令
cd /etc/apt && mv sources.list sources.list.bk && echo -e " deb http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse" > sources.list