Debian

apt upgrade 在 docker 容器內以程式碼 137 退出

  • March 18, 2022

在添加我自己的文件之前,我正在嘗試升級基於 Python:3.9 的 docker 映像中的軟體包。我嘗試apt upgrade -y在具有基本映像的互動式容器中以及作為Dockerfile建構的一部分執行該命令。

python:3.9 映像基於 Debian 11 - Bullseye OS 建構。

在這兩種情況下,我都會在 docker 環境中收到以下錯誤。

$ docker run -it --name python_te
st python:3.9 sh
# apt update
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]     
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]                    
Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [121 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2596 B]
Fetched 8506 kB in 3s (2606 kB/s)                         
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
6 packages can be upgraded. Run 'apt list --upgradable' to see them.
# apt upgrade -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
 libexpat1 libexpat1-dev libssl-dev libssl1.1 linux-libc-dev openssl
6 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 5919 kB of archives.
After this operation, 24.6 kB of additional disk space will be used.
Get:1 http://security.debian.org/debian-security bullseye-security/main amd64 libssl-dev amd64 1.1.1k-1+
deb11u2 [1810 kB]
Get:2 http://security.debian.org/debian-security bullseye-security/main amd64 libssl1.1 amd64 1.1.1k-1+d
eb11u2 [1554 kB]
Get:3 http://security.debian.org/debian-security bullseye-security/main amd64 libexpat1-dev amd64 2.2.10
-2+deb11u3 [141 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 libexpat1 amd64 2.2.10-2+d
eb11u3 [98.5 kB]
Get:5 http://security.debian.org/debian-security bullseye-security/main amd64 linux-libc-dev amd64 5.10.
103-1 [1466 kB]
Get:6 http://security.debian.org/debian-security bullseye-security/main amd64 openssl amd64 1.1.1k-1+deb
11u2 [850 kB]
Fetched 5919 kB in 2s (2652 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 23373 files and directories currently installed.)
Preparing to unpack .../libssl-dev_1.1.1k-1+deb11u2_amd64.deb ...
Unpacking libssl-dev:amd64 (1.1.1k-1+deb11u2) over (1.1.1k-1+deb11u1) ...
Preparing to unpack .../libssl1.1_1.1.1k-1+deb11u2_amd64.deb ...
Unpacking libssl1.1:amd64 (1.1.1k-1+deb11u2) over (1.1.1k-1+deb11u1) ...
Setting up libssl1.1:amd64 (1.1.1k-1+deb11u2) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /u
sr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
(Reading database ... 23373 files and directories currently installed.)
Preparing to unpack .../libexpat1-dev_2.2.10-2+deb11u3_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.2.10-2+deb11u3) over (2.2.10-2+deb11u2) ...
Preparing to unpack .../libexpat1_2.2.10-2+deb11u3_amd64.deb ...
Unpacking libexpat1:amd64 (2.2.10-2+deb11u3) over (2.2.10-2+deb11u2) ...
Preparing to unpack .../linux-libc-dev_5.10.103-1_amd64.deb ...
Unpacking linux-libc-dev:amd64 (5.10.103-1) over (5.10.92-1) ...
Killed
     # 

互動式容器然後變得無響應,並且 docker 建構失敗並顯示附加資訊:

...
Unpacking linux-libc-dev:amd64 (5.10.103-1) over (5.10.92-1) ...
Killed
The command '/bin/sh -c apt update && apt upgrade' returned a non-zero code: 137

我嘗試將記憶體限制設置為 16g,因為我看到有人說 137 記憶體不足,但它仍然失敗。

有關如何安裝更新的任何建議?

有多個明顯的錯誤可以很容易地修復:

錯誤一:

debconf: delaying package configuration, since apt-utils is not installed

通過以下方式修復:

sudo apt -y install apt-utils

錯誤2:

No usable dialog-like program is installed

通過以下方式修復:

sudo apt -y install dialog

引用自:https://unix.stackexchange.com/questions/695933