使用 docker pull python:3.9.9-slim
拉取 docker hub
中的 python
镜像
使用 docker run --rm -it python:3.9.9-slim /bin/bash
运行镜像
发现预装了 apt
但是没有 rpm 和 pacman 等!
查看 /etc/apt/sources.list
内容发现是 debian
而不是 ubuntu 的软件源
root@a18e550f7700:/# cat /etc/apt/sources.list
# deb http://snapshot.debian.org/archive/debian/20211201T000000Z bullseye main
deb http://deb.debian.org/debian bullseye main
# deb http://snapshot.debian.org/archive/debian-security/20211201T000000Z bullseye-security main
deb http://security.debian.org/debian-security bullseye-security main
# deb http://snapshot.debian.org/archive/debian/20211201T000000Z bullseye-updates main
deb http://deb.debian.org/debian bullseye-updates main
我有几个疑问:
- 为什么 docker 镜像默认的包管理都是 apt 而不是 rpm 或者 pacman 呢?
- 镜像中采用哪个包管理器是否取决于宿主机平台,比如宿主机是 debian 系用 apt,是 redhat 系用 rpm
- 为什么在宿主机是 ubuntu ,容器中的软件源是 debian 呢?
apt用得比较多,可能是国外debian比较流行吧。