由于 libc-bin 分段错误,无法为arm64构建Dockerfile

use*_*014 6 package-management apt

我在尝试为该平台构建 Dockerfile 时收到以下错误linux/arm64

#5 58.06 Processing triggers for libc-bin (2.31-11) ...
#5 58.12 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#5 58.33 Segmentation fault (core dumped)
#5 58.35 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#5 58.69 Segmentation fault (core dumped)
#5 58.70 dpkg: error processing package libc-bin (--configure):
#5 58.70  installed libc-bin package post-installation script subprocess returned error exit status 139
#5 58.70 Processing triggers for ca-certificates (20210119) ...
#5 58.87 Updating certificates in /etc/ssl/certs...
#5 71.86 0 added, 0 removed; done.
#5 71.86 Running hooks in /etc/ca-certificates/update.d...
#5 71.89 done.
#5 71.98 Errors were encountered while processing:
#5 71.98  libc-bin
#5 72.06 E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

我已将 Dockerfile 一直修剪为以下内容:

FROM kalilinux/kali-rolling
ARG DEBIAN_FRONTEND=noninteractive
ARG TARGETPLATFORM
RUN apt update && \
    apt install wget -y
Run Code Online (Sandbox Code Playgroud)

解决方案尝试#1

我首先想到的是:https: //stackoverflow.com/questions/59139453/repository-is-not-signed-in-docker-build/66215465#66215465。我在 ARM 32 位处理器上安装东西时遇到了这个问题,所以我尝试将相同的依赖项添加到这个 Dockerfile 中,但没有成功。这些依赖项是:

然而,问题仍然存在。

解决方案尝试#2

我跑过https://github.com/docker/for-linux/issues/1131并尝试附加-o APT::Immediate-Configure=0以获取我的apt install命令,但这也不起作用。

解决方案尝试#3

接下来,我遇到了这个答案: https: //askubuntu.com/a/1035226/269349。当我将 Dockerfile 修改为如下所示时:

FROM kalilinux/kali-rolling
ARG DEBIAN_FRONTEND=noninteractive
ARG TARGETPLATFORM
RUN apt update && \
  rm /var/cache/ldconfig/aux-cache && \
  /sbin/ldconfig && \
  apt install wget -y -o APT::Immediate-Configure=0
Run Code Online (Sandbox Code Playgroud)

我开始收到的下一个错误是:

 => ERROR [2/2] RUN apt update &&   rm /var/cache/ldconfig/aux-cache &&   /sbin/ldconfig &&   apt install wget -y -o APT::Immediate-Configure=0                                                                                                                                                                                                                       77.8s
------
 > [2/2] RUN apt update &&   rm /var/cache/ldconfig/aux-cache &&   /sbin/ldconfig &&   apt install wget -y -o APT::Immediate-Configure=0:
#5 0.203
#5 0.204 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#5 0.205
#5 1.055 Get:1 http://mirrors.jevincanders.net/kali kali-rolling InRelease [30.5 kB]
#5 3.496 Get:2 http://mirrors.jevincanders.net/kali kali-rolling/non-free arm64 Packages [157 kB]
#5 4.211 Get:3 http://mirrors.jevincanders.net/kali kali-rolling/main arm64 Packages [17.5 MB]
#5 67.37 Get:4 http://mirrors.jevincanders.net/kali kali-rolling/contrib arm64 Packages [87.3 kB]
#5 71.57 Fetched 17.8 MB in 1min 11s (249 kB/s)
#5 71.57 Reading package lists...
#5 76.73 Building dependency tree...
#5 77.44 Reading state information...
#5 77.51 4 packages can be upgraded. Run 'apt list --upgradable' to see them.
#5 77.55 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#5 77.74 Segmentation fault (core dumped)
------
Dockerfile:4
--------------------
   3 |     ARG TARGETPLATFORM
   4 | >>> RUN apt update && \
   5 | >>>   rm /var/cache/ldconfig/aux-cache && \
   6 | >>>   /sbin/ldconfig && \
   7 | >>>   apt install wget -y -o APT::Immediate-Configure=0
   8 |
--------------------
Run Code Online (Sandbox Code Playgroud)

解决方案尝试#4

我尝试了上一个答案(重新安装 libc-bin)下面的答案,但后来遇到了这个问题:

#4 25.05 Get:1 http://mirrors.jevincanders.net/kali kali-rolling/main arm64 libc-bin arm64 2.31-11 [735 kB]
#4 27.93 debconf: delaying package configuration, since apt-utils is not installed
#4 28.12 Fetched 735 kB in 2s (295 kB/s)
(Reading database ... 6748 files and directories currently installed.)
#4 28.30 Preparing to unpack .../libc-bin_2.31-11_arm64.deb ...
#4 28.32 Unpacking libc-bin (2.31-11) over (2.31-11) ...
#4 28.84 Setting up libc-bin (2.31-11) ...
#4 28.98 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#4 29.20 Segmentation fault (core dumped)
#4 29.22 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#4 29.42 Segmentation fault (core dumped)
#4 29.42 dpkg: error processing package libc-bin (--configure):
#4 29.42  installed libc-bin package post-installation script subprocess returned error exit status 139
#4 29.43 Errors were encountered while processing:
#4 29.43  libc-bin
#4 29.51 E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

这是我正在运行的命令:docker buildx build --platform linux/arm64 .

任何帮助将不胜感激。

elb*_*ero 0

根据这个错误报告,这似乎是内核中的一个错误,应该通过将内核更新到最新版本来解决: https: //bugs.launchpad.net/ubuntu/+source/qemu/+bug/ 1928075

我可以在 GitLab CI 中重现这个 bug,而且似乎只有架构arm64会触发这个 bug。armhf就很好: https: //gitlab.com/arnaudr/test-binfmt-misc/-/pipelines/356065926/builds


rfa*_*fay 0

我能够通过使用最新的 qemu 5 在 Ubuntu 20.04 上解决这个问题

sudo add-apt-repository ppa:jacob/virtualisation (for Ubuntu 20.04)
sudo apt-get update && sudo apt-get install qemu qemu-user qemu-user-static
Run Code Online (Sandbox Code Playgroud)