ubuntu24.04 debian 12 使用国内源
和以前不一样了不再是sources.list而是 ubuntu.sources
ubuntu24.04
/etc/apt/sources.list.d/ubuntu.sources
Types: deb
URIs: https://mirrors.aliyun.com/ubuntu
Suites: noble noble-updates noble-security noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
debian12
/etc/apt/sources.list.d/debian.sources
Types: deb URIs: https://mirrors.aliyun.com/debian Suites: bookworm bookworm-updates bookworm-backports Components: main contrib non-free non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg Types: deb URIs: https://mirrors.aliyun.com/debian-security Suites: bookworm-security Components: main contrib non-free non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
DEB822 格式说明:
-
Types: deb表示二进制软件包(deb-src可添加以支持源码包)。 -
URIs指定镜像地址(阿里云)。 -
Suites对应 Ubuntu 24.04 的版本代号noble及其更新分支(noble-updates、noble-security、noble-backports)。 -
Components指定软件分类(main、restricted、universe、multiverse)。
DEB822 格式的优势
-
结构化清晰:支持多行配置,便于管理多个仓库和组件。
-
兼容性:APT 1.1(2015 年)起已支持,但直到 Debian 12 容器镜像才默认启用24。
-
安全性:支持签名密钥的显式指定(
Signed-By字段)36。
ubuntu 和 debian的区别
| 分类 | Ubuntu/Linux Mint | Debian | 是否过时 |
|---|---|---|---|
| main | ✅ | ✅ | 否 |
| restricted | ✅ | ❌ | 否 |
| universe | ✅ | ❌ | 否 |
| multiverse | ✅ | ❌ | 否 |
| contrib | ❌ | ✅ | 否 |
| non-free | ❌ | ✅ | 否 |
-
Ubuntu 用户:关注
main/universe/multiverse。 -
Debian 用户:按需添加
contrib/non-free。
对比老版22.04 的 sources.list写法
#ubuntu 22.04版 # 基础仓库 deb http://mirrors.aliyun.com/ubuntu jammy main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu jammy-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu jammy-security main restricted universe multiverse # 可选仓库 deb http://mirrors.aliyun.com/ubuntu jammy-backports main restricted universe multiverse
其实就是避免了重复写网址 和雷同软件分类(main、restricted、universe、multiverse)
从SPOT(真理单点性)来说,每种东西只写1便,显然是进步了。
docker-compose.yml 这样写
services:
app:
build: .
volumes:
- .ubuntu.sources:/etc/apt/sources.list.d/ubuntu.sources # 覆盖默认源
python官方镜像是基于debian的。国内使用时定制一下,加快下载速度。
1 debian本身使用国内源
dockfile中:
#国内debian源ADD sources.list /etc/apt/
deb http://mirrors.ustc.edu.cn/debian/ stretch main non-free contrib
deb http://mirrors.ustc.edu.cn/debian/ stretch-updates main non-free contrib
deb http://mirrors.ustc.edu.cn/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian/ stretch main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian/ stretch-backports main non-free contrib
deb http://mirrors.ustc.edu.cn/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian-security/ stretch/updates main non-free contrib
2 pip使用国内源
#用国内源加速大包的安装sudo cp pip.conf /etc/pip.conf
pip.conf
[global]index-url = https://pypi.tuna.tsinghua.edu.cn/simple

浙公网安备 33010602011771号