为什么我把 debian12 的 apt 源替换为上海交大之后,还会连接 debian 官方源?-灵析社区

刘一抗二二

用 Docker 做演示 选用一个使用 debian12 bookworm 作为基础镜像的 python 镜像 FROM python:3.11.5-bookworm RUN echo "deb http://mirror.sjtu.edu.cn/debian bookworm main non-free contrib" > /etc/apt/sources.list 打包镜像 docker build -t "ponponon/image_search_engine:2023.09.07.1" . 打开容器 docker run -it --rm ponponon/image_search_engine:2023.09.07.1 bash 查看镜像文件 alias ll="ls -alh" cd /etc/apt/ cat sources.list 内容如下: root@49008ea43dda:/etc/apt# cat sources.list deb http://mirror.sjtu.edu.cn/debian bookworm main non-free contrib 确实只有 sjtu 了 但是当我执行 apt update 的时候 root@49008ea43dda:/etc/apt# apt update Get:1 http://mirror.sjtu.edu.cn/debian bookworm InRelease [151 kB] Get:2 http://deb.debian.org/debian bookworm InRelease [151 kB] Get:3 http://mirror.sjtu.edu.cn/debian bookworm/main amd64 Packages [8906 kB] Get:4 http://mirror.sjtu.edu.cn/debian bookworm/non-free amd64 Packages [98.6 kB] Get:5 http://mirror.sjtu.edu.cn/debian bookworm/contrib amd64 Packages [54.3 kB] Get:6 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB] Get:7 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB] Get:8 http://deb.debian.org/debian bookworm/main amd64 Packages [8906 kB] 59% [8 Packages 331 kB/8906 kB 4%]^C 为什么还会连接 `http://deb.debian.org/debian` 呢? * * * 是的,正如「Feng_Yu」所说,所以要加一行 `RUN rm -rf /etc/apt/sources.list.d/*` > 注意,海外不要删除,不然就废了。大陆要换成 aliyun 、中科大等 apt 镜像源的才需要这样操作 完整的: FROM python:3.11.5-bookworm RUN rm -rf /etc/apt/sources.list.d/* RUN echo "deb http://mirror.sjtu.edu.cn/debian bookworm main non-free contrib" > /etc/apt/sources.list RUN apt update

阅读量:333

点赞量:19

问AI
debian 12改了,默认不使用"/etc/apt/sources.list"文件,这个文件初始是空的,真正的仓库配置在 "/etc/apt/sources.list.d/" 目录下,并且格式不是以前常见的简化格式( ONE-LINE-STYLE FORMAT ),而是被称为 "deb822"的新格式,新格式参考: "https://www.debian.org/doc/manuals/debian-reference/ch02#_deb..." (https://link.segmentfault.com/?enc=yCBBCelq9n0dk0TCJTHb%2Fw%3D%3D.tl1sKnAE9d1gFwbaCJFnlpaCYDFT0F2dvvp0ABBOLPHkCp%2BYCQ2bCF%2BmwMpPCh0qU9aJj1tXu9bndbjqSiF7rabJyVZqrTN%2BC3YYDiiANzA%3D) 并且在debian的man手册中提到,deb822的引入会逐步废弃掉老的one-line format: "https://manpages.debian.org/bookworm/apt/sources.list.5.en.html" (https://link.segmentfault.com/?enc=2fi%2BRTNszASxWeAtFUfxBw%3D%3D.bPFmAQfGsR3bA%2Fl1Pby1fwBxCnKpeYhtLc5RTdLhcCjTnctsjeoDVQx%2ByL0y7ymt79092kjtyEF0zvd4jliKDw%3D%3D) 在 DEB822-STYLE FORMAT 章节下有这样的说明 «This is a new format supported by apt itself since version 1.1. Previous versions ignore such files with a notice message as described earlier. It is intended to make this format gradually the default format, deprecating the previously described one-line-style format, as it is easier to create, extend and modify for humans and machines alike especially if a lot of sources and/or options are involved. Developers who are working with and/or parsing apt sources are highly encouraged to add support for this format and to contact the APT team to coordinate and share this work. Users can freely adopt this format already, but may encounter problems with software not supporting the format yet.» 你需要一并删除"/etc/apt/sources.list.d/"目录下的文件才行