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-updatesnoble-securitynoble-backports)。

  • Components 指定软件分类(mainrestricteduniversemultiverse)。

 

DEB822 格式的优势

  • 结构化清晰:支持多行配置,便于管理多个仓库和组件。

  • 兼容性:APT 1.1(2015 年)起已支持,但直到 Debian 12 容器镜像才默认启用24。

  • 安全性:支持签名密钥的显式指定(Signed-By 字段)36。

 

ubuntu 和 debian的区别

分类Ubuntu/Linux MintDebian是否过时
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

其实就是避免了重复写网址 和雷同软件分类(mainrestricteduniversemultiverse

从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/
sources.list在dockerfile同目录下:

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 

 

 

posted @ 2018-12-05 15:48  永远的幻想  阅读(4990)  评论(0)    收藏  举报