apt Upgrade 在 docker 容器内退出并显示代码 137

apt Upgrade 在 docker 容器内退出并显示代码 137

我正在尝试在添加我自己的文件之前升级基于 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 内存不足,但它仍然失败。

关于如何安装更新有什么建议吗?

答案1

有多个明显的错误可以轻松修复:

错误1:

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

相关内容