Sample Header Ad - 728x90

Some binaries are extremely slow with qemu-user-static inside docker

2 votes
1 answer
1349 views
I'm currently working with the [armbian build system](https://github.com/armbian/build) and it is using chroot inside docker to cross build armbian images (for aarch64 in my case on an amd64 host). However, for some reason, when the build script is executing apt-key add - takes literally hours on my machine while constantly using 100% of a single CPU core. Apt key is called like this: chroot bash -c 'cat armbian.key | apt-key add -', resulting in a process like /usr/bin/qemu-aarch64-static /bin/bash -c cat armbian.key | apt-key add - inside the container. Inside apt-key (which is a shell script) a few binaries are called which is what actually takes that long, such as: - multiple calls to /usr/bin/apt-config, e.g. /usr/bin/apt-config shell ARCHIVE_KEYRING_URI APT::Key::Archiv. - a call to /usr/bin/gpg-conf (/usr/bin/gpgconf --kill all to be exact) - possibly more, but I might have missed some (was looking at ps aux occasionally while waiting) I'm really clueless, why these calls, that are supposed to take seconds at most, take hours to terminate when executed via docker -> chroot -> qemu. I really don't understand what makes this so slow. I would be very thankful for any pointers on how to debug this further. **EDIT:** I should mention that the steps in question are significantly faster when executed directly on an ubuntu 22.04 VM (in which case the armbian build script doesn't use docker, because Ubuntu 22.04 is supported natively). **EDIT:** I managed to reproduce the issue like this:
docker run --name armbian-test -d --rm ghcr.io/armbian/docker-armbian-build:armbian-ubuntu-jammy-latest bash -c 'while sleep 1; do true; done'
docker exec armbian-test bash -c 'apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends bash git psmisc uuid-runtime bc binfmt-support bison libc6-dev make dpkg-dev gcc ca-certificates ccache cpio debootstrap device-tree-compiler dialog dirmngr dosfstools dwarves flex gawk gnupg gpg imagemagick jq kmod libbison-dev libelf-dev libfdt-dev libfile-fcntllock-perl libmpc-dev libfl-dev liblz4-tool libncurses-dev libssl-dev libusb-1.0-0-dev linux-base locales lsof ncurses-base ncurses-term ntpdate patchutils pkg-config pv qemu-user-static rsync swig u-boot-tools udev uuid-dev zlib1g-dev file tree expect colorized-logs unzip zip pigz xz-utils pbzip2 lzop zstd parted gdisk fdisk aria2 curl wget axel parallel python3-dev python3-distutils python3-setuptools python3-pip python2 python2-dev gcc-x86-64-linux-gnu gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi gcc-riscv64-linux-gnu debian-archive-keyring libc6-amd64-cross g++-aarch64-linux-gnu g++ btrfs-progs cryptsetup openssh-client f2fs-tools nilfs-tools xfsprogs zerofree qemu-utils qemu-utils libudev-dev libusb-1.0-0-dev dh-autoreconf build-essential gcc-arm-linux-gnueabi gcc-or1k-elf time'
docker exec armbian-test debootstrap --variant=minbase --arch=arm64 bullseye /debootstrap
docker exec armbian-test time chroot /debootstrap /bin/bash -c '/usr/bin/apt-config shell ARCHIVE_KEYRING_URI APT::Key::Archiv'
Asked by theCalcaholic (188 rep)
Oct 17, 2023, 03:22 PM
Last activity: Feb 17, 2024, 01:10 AM