How to: 在容器映像檔找到已安裝的套件清單
Steps
以 mcr.microsoft.com/azure-functions/dotnet:4.22.0
為例
0. Run Container Images
$ docker run -it --rm --name debug mcr.microsoft.com/azure-functions/dotnet:4.22.0 bash
root@b6c53359372d:/#
1. Check Base Images from CLI
You should use cat /etc/os-realese
to check the base images instead of uname -a
- Correct
root@b6c53359372d:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
- Incorrect: The kernel version is shown from the host machine, not container images
root@b6c53359372d:/# uname -a
Linux b6c53359372d 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 GNU/Linux
2. Check Installed Packages
root@b6c53359372d:/# apt list --installed
Listing... Done
adduser/oldstable,now 3.118 all [installed,automatic]
apt/oldstable,now 2.2.4 amd64 [installed,automatic]
base-files/oldstable,now 11.1+deb11u7 amd64 [installed,automatic]
base-passwd/oldstable,now 3.5.51 amd64 [installed,automatic]
bash/oldstable,now 5.1-2+deb11u1 amd64 [installed,automatic]
bsdutils/oldstable,oldstable-security,now 1:2.36.1-8+deb11u1 amd64 [installed,automatic]
ca-certificates/oldstable,now 20210119 all [installed]
coreutils/oldstable,now 8.32-4+b1 amd64 [installed,automatic]
dash/oldstable,now 0.5.11+git20200708+dd9ef66-5 amd64 [installed,automatic]
debconf/oldstable,now 1.5.77 all [installed,automatic]
debian-archive-keyring/oldstable,now 2021.1.1+deb11u1 all [installed,automatic]
...omit...
3. List Package Dependencies with apt depends
root@b6c53359372d:/# apt depends bash
bash
PreDepends: libc6 (>= 2.25)
PreDepends: libtinfo6 (>= 6)
Depends: base-files (>= 2.1.12)
Depends: debianutils (>= 2.15)
Conflicts: bash-completion (<< 20060301-0)
Recommends: bash-completion (>= 20060301-0)
Suggests: bash-doc
Replaces: bash-completion (<< 20060301-0)
Replaces: bash-doc (<= 2.05-1)
4. List Package Information with apt show
root@b6c53359372d:/# apt show linux-libc-dev
Package: linux-libc-dev
Version: 5.10.179-1
Priority: optional
Section: devel
Source: linux
Maintainer: Debian Kernel Team <[email protected]>
Installed-Size: 6025 kB
Homepage: https://www.kernel.org/
Download-Size: 1618 kB
APT-Manual-Installed: no
APT-Sources: http://deb.debian.org/debian-security bullseye-security/main amd64 Packages
Description: Linux support headers for userspace development
root@b6c53359372d:/#
5. Known which package can be upgrade
root@b6c53359372d:/# apt update
Hit:1 http://deb.debian.org/debian bullseye InRelease
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [246 kB]
Fetched 339 kB in 1s (431 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@b6c53359372d:/# apt list --upgradeable
Listing... Done
libx11-6/oldstable-security 2:1.7.2-1+deb11u1 amd64 [upgradable from: 2:1.7.2-1]
libx11-data/oldstable-security 2:1.7.2-1+deb11u1 all [upgradable from: 2:1.7.2-1]
root@b6c53359372d:/#