buildx: Error building python 3.6 slim

I have this Dockerfile:

FROM python:3.6-slim

RUN apt-get update && apt-get install -y --no-install-recommends make

When I run this command:

docker buildx build . --pull --platform linux/arm/v5

I get this output:

WARN[0000] No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load                                                                                       
[+] Building 27.3s (6/6) FINISHED                                     
 => [internal] load build definition from Dockerfile                                                                                                                                                          0.0s                                                                        
 => => transferring dockerfile: 129B                                                                                                                                                                          0.0s                                                                        
 => [internal] load .dockerignore                                                                                                                                                                             0.0s                                                                        
 => => transferring context: 2B                                                                                                                                                                               0.0s                                                                        
 => [internal] load metadata for docker.io/library/python:3.6-slim                                                                                                                                            0.6s                                                                        
 => [auth] library/python:pull token for registry-1.docker.io                                                                                                                                                 0.0s                                                                        
 => CACHED [1/2] FROM docker.io/library/python:3.6-slim@sha256:200bc4213e83751cc4a5496e72573ce8173713fc73266a1fd3ec62bd378a5890                                                                               0.0s                                                                        
 => => resolve docker.io/library/python:3.6-slim@sha256:200bc4213e83751cc4a5496e72573ce8173713fc73266a1fd3ec62bd378a5890                                                                                      0.0s                                                                        
 => ERROR [2/2] RUN apt-get update && apt-get install -y --no-install-recommends make                                                                                                                        26.6s                                                                        
------                                                                
 > [2/2] RUN apt-get update && apt-get install -y --no-install-recommends make:                                                              
#6 0.582 Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]                                                 
#6 0.583 Get:2 http://deb.debian.org/debian buster InRelease [121 kB] 
#6 0.679 Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]                                                               
#6 2.670 Get:4 http://security.debian.org/debian-security buster/updates/main armel Packages [232 kB]                                        
#6 4.570 Get:5 http://deb.debian.org/debian buster/main armel Packages [7627 kB]                                                             
#6 6.556 Get:6 http://deb.debian.org/debian buster-updates/main armel Packages [7860 B]                                                      
#6 8.912 Fetched 8106 kB in 8s (962 kB/s)                             
#6 8.912 Reading package lists...                                     
#6 16.39 Reading package lists...                                     
#6 23.71 Building dependency tree...                                  
#6 24.28 Reading state information...                                 
#6 24.65 Suggested packages:                                          
#6 24.65   make-doc                                                   
#6 25.19 The following NEW packages will be installed:                                                                                       
#6 25.19   make                                                       
#6 25.39 0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.                                                                      
#6 25.39 Need to get 327 kB of archives.                              
#6 25.39 After this operation, 1300 kB of additional disk space will be used.                                                                
#6 25.39 Get:1 http://deb.debian.org/debian buster/main armel make armel 4.2.1-1.2 [327 kB]                                                  
#6 26.17 debconf: delaying package configuration, since apt-utils is not installed                                                           
#6 26.29 Fetched 327 kB in 0s (2000 kB/s)                             
#6 26.37 Error while loading /usr/sbin/dpkg-split: No such file or directory                                                                 
#6 26.38 Error while loading /usr/sbin/dpkg-deb: No such file or directory                                                                   
#6 26.38 dpkg: error processing archive /var/cache/apt/archives/make_4.2.1-1.2_armel.deb (--unpack):                                         
#6 26.38  dpkg-deb --control subprocess returned error exit status 1                                                                         
#6 26.40 Errors were encountered while processing:                    
#6 26.40  /var/cache/apt/archives/make_4.2.1-1.2_armel.deb                                                                                   
#6 26.50 E: Sub-process /usr/bin/dpkg returned an error code (1)                                                                             
------                                                                
Dockerfile:3                                                          
--------------------                                                  
   1 |     FROM python:3.6-slim                                       
   2 |                                                                
   3 | >>> RUN apt-get update && apt-get install -y --no-install-recommends make                                                             
   4 |                                                                
--------------------                                                  
error: failed to solve: rpc error: code = Unknown desc = executor failed running [/dev/.buildkit_qemu_emulator /bin/sh -c apt-get update && apt-get install -y --no-install-recommends make]: exit code: 100

Some observations:

It seems like it’s looking for /usr/sbin/dpkg-split and /usr/sbin/dpkg-deb, even though those are located in the /usr/bin folder.

Platforms linux/arm/v7 and linux/arm/v8 both fail, however linux/amd64 does not fail.

Changing my Dockerfile to use FROM python:3.6 (instead of slim) builds correctly for all cases (armv5, armv7, arm64v8, amd64), and manually starting a container (after doing the multiarch qemu setup) with docker run -it --rm arm32v5/python:3.6-slim bash allows me to install make just fine.

I wasn’t sure if this was a buildx issue or just a python-slim issue, but I was also able to do this as my Dockerfile:

FROM arm32v5/python:3.6-slim

RUN apt-get update && apt-get install -y --no-install-recommends make

and do a regular docker build:

docker build . --pull

and it builds correctly. So my guess is it has something to do with buildx? Unless arm32v5/python:3.6-slim is different than python:3.6-slim that buildx would be pulling.

This might be related to #493, not entirely sure.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 16
  • Comments: 35

Commits related to this issue

Most upvoted comments

What actually solved my problem after two painful days was creating the following custom builder:

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch --driver docker-container --use
docker buildx inspect --bootstrap

Now I can successfully run:

docker buildx build --platform linux/arm64 -t user/repo --no-cache --pull .

on my linux/amd64 machine.

While trying I saw that there is an update to docker 20.10.2. Don’t know if this did the trick, but now it works.

However in the process I also did a docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Found the same problem when I tried to build arm64 image and included apt-get install iputils-ping in my Dockerfile (my base image is openjdk:11-jre-slim, however).

The solution proposed by pcko1 didn’t work for me but the solution proposed by junka worked. Just adding several soft links before apt-get:

RUN ln -s /usr/bin/dpkg-split /usr/sbin/dpkg-split
RUN ln -s /usr/bin/dpkg-deb /usr/sbin/dpkg-deb
RUN ln -s /bin/rm /usr/sbin/rm
RUN ln -s /bin/tar /usr/sbin/tar

It’s even more confusing when I found I can apt-get directly inside container running on raspberrypi.

pi@raspberrypi:~ $ sudo docker run  --privileged -it --rm openjdk:11-jre-slim-bullseye sh -c " apt-get update && apt-get install -y iputils-ping && ping -c 4 www.baidu.com"
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 arm64 Packages [97.0 kB]
Get:5 http://deb.debian.org/debian bullseye/main arm64 Packages [8068 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main arm64 Packages [2600 B]                                         
Fetched 8367 kB in 45s (188 kB/s)                                                                                        
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcap2 libcap2-bin libpam-cap
The following NEW packages will be installed:
  iputils-ping libcap2 libcap2-bin libpam-cap
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 119 kB of archives.
After this operation, 315 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main arm64 libcap2 arm64 1:2.44-1 [23.2 kB]
Get:2 http://deb.debian.org/debian bullseye/main arm64 libcap2-bin arm64 1:2.44-1 [32.0 kB]
Get:3 http://deb.debian.org/debian bullseye/main arm64 iputils-ping arm64 3:20210202-1 [48.3 kB]
Get:4 http://deb.debian.org/debian bullseye/main arm64 libpam-cap arm64 1:2.44-1 [15.5 kB]
Fetched 119 kB in 0s (458 kB/s)    
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libcap2:arm64.
(Reading database ... 7055 files and directories currently installed.)
Preparing to unpack .../libcap2_1%3a2.44-1_arm64.deb ...
Unpacking libcap2:arm64 (1:2.44-1) ...
Selecting previously unselected package libcap2-bin.
Preparing to unpack .../libcap2-bin_1%3a2.44-1_arm64.deb ...
Unpacking libcap2-bin (1:2.44-1) ...
Selecting previously unselected package iputils-ping.
Preparing to unpack .../iputils-ping_3%3a20210202-1_arm64.deb ...
Unpacking iputils-ping (3:20210202-1) ...
Selecting previously unselected package libpam-cap:arm64.
Preparing to unpack .../libpam-cap_1%3a2.44-1_arm64.deb ...
Unpacking libpam-cap:arm64 (1:2.44-1) ...
Setting up libcap2:arm64 (1:2.44-1) ...
Setting up libcap2-bin (1:2.44-1) ...
Setting up libpam-cap:arm64 (1:2.44-1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/aarch64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/aarch64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/aarch64-linux-gnu/perl-base /usr/lib/aarch64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up iputils-ping (3:20210202-1) ...
Processing triggers for libc-bin (2.31-13+deb11u2) ...
PING www.a.shifen.com (182.61.200.7) 56(84) bytes of data.
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=1 ttl=51 time=6.87 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=2 ttl=51 time=14.6 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=3 ttl=51 time=11.4 ms
64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=4 ttl=51 time=4.49 ms

--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 4.485/9.329/14.598/3.917 ms
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.10.17-v8+ #1414 SMP PREEMPT Fri Apr 30 13:23:25 BST 2021 aarch64 GNU/Linux

Just in case you are using Github Actions and the were trying the workarounds mentioned earlier, there may be a much more obvious solution for you: use the docker/setup-qemu-action in a step before setting up Docker Buildx:

      - name: Set up QEMU
        id: qemu
        uses: docker/setup-qemu-action@v1
        with:
          image: tonistiigi/binfmt:latest
          platforms: all

      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v1

This at least solved it for me – without any further workarounds like symlinking from /usr/bin to /usr/sbin.

Just in case you are using Github Actions and the were trying the workarounds mentioned earlier, there may be a much more obvious solution for you: use the docker/setup-qemu-action in a step before setting up Docker Buildx:

      - name: Set up QEMU
        id: qemu
        uses: docker/setup-qemu-action@v1
        with:
          image: tonistiigi/binfmt:latest
          platforms: all

      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v1

This at least solved it for me – without any further workarounds like symlinking from /usr/bin to /usr/sbin.

Bump on this! Worked for me. I would just recommend not using latest.

@pcko1 your suggestion resolved my issue also, cheers mate! 😃

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes docker buildx create --name multiarch --driver docker-container --use docker buildx inspect --bootstrap

@rxue92 I just had the same problem. You should have a look at /proc/sys/fs/binfmt_misc/ and see if there are conflicting entries for the same architecture (arm64 in your case). I found a duplicate and remove the non-qemu one like this:

docker run --privileged --rm tonistiigi/binfmt --uninstall armv7l-linux

In my case, it was an entry created by the OS for cross-compiling, so I had to remove it in order to get the docker builds working.

I am getting the exact same problem when I build with this dockerfile:

# syntax=docker/dockerfile:experimental

FROM arm64v8/ubuntu:latest
RUN apt-get update
RUN apt-get install -y --no-install-recommends
RUN apt-get install -y build-essential
...

which results in:

...
=> ERROR [ 4/20] RUN apt-get install -y build-essential
...
> Error while loading /usr/sbin/dpkg-split: No such file or directory
> Error while loading /usr/sbin/dpkg-deb: No such file or directory
...

For the record, I am cross-building on ubuntu 20.04 / amd64 and for a raspberry pi 4 target machine (ubuntu server 20.10 / arm64) using buildx and the following command:

docker buildx build --platform linux/arm64 -t user/repo --no-cache --pull .

My custom builder looks like this:

NAME/NODE  DRIVER/ENDPOINT             STATUS  PLATFORMS
mybuilder *  docker-container                    
  mybuilder unix:///var/run/docker.sock running linux/arm64*, linux/amd64*, linux/386

Any ideas?

I investigated a similar issue (same error message) and came to the following conclusion:

  • The problem is often not with the binfmt registration itself as suggested above and elsewhere.
  • Instead, older Debian and Ubuntu releases ship a broken/bastardized qemu. They apply loads of custom patches on top of upstream qemu, one of which presumably breaks the emulation. E.g. on Ubuntu 18.04 which ships the old qemu release 2.11.1 I get these apt-get crashes. When compiling the same qemu version from the upstream sources (without Debian/Ubuntu patches), it works fine.
  • The reason why workarounds like docker run --rm --privileged multiarch/qemu-user-static --reset -p yes help here, is because they force the kernel to load working qemu binaries contained within the Docker image instead of taking the system’s broken qemu. Beware that you are effectively loading third-party binaries as root, which are nowhere to be found on the host’s disk after the container stops (they live in-memory).

Also experiencing this on a daemonless build. What can I do in my case?

In my case running:

docker run --privileged --rm tonistiigi/binfmt --install all

once again to update the previous installation fixed the issues.

don’t know the root cause, add these in dockerfile would help

RUN ln -s /usr/bin/dpkg-split /usr/sbin/dpkg-split
RUN ln -s /usr/bin/dpkg-deb /usr/sbin/dpkg-deb
RUN ln -s /bin/tar /usr/sbin/tar

soft link path could be different

@JesseBowling

In my experimentations, you run into issues if you create a builder. Things work fine if you use the default builder and don’t multi platform build (not that you can with the default builder anyway). Is this your experience as well?

@atam003 from my understanding : check that all your images, including the ones used by the builders, support all the invoked CPU architectures.

docker buildx ls will print this info for your current builders

But why was is it working before the system update?

I can confirm this, our last successful build was on the 26.01.2021.

I wouldn’t see this Issue as closed or fixed.

Just an update after reading though all the comments here and trying out some solutions:

I am primarily using GitHub Actions to do my building with Buildx, hopefully what I was able to reproduce on my own machine closely matches what GitHub Actions was doing. I realized that the list of Buildx platforms supported in GitHub Actions did not include linux/arm/v5. Once I removed that from my build workflow, the build was successful!

It’s weird, because having linux/arm/v5 didn’t break things before, but perhaps some change happened 2 months ago and now it does break. Probably for the best though, as I’m going to assume whatever was being built might not have been guaranteed to be arm/v5 compatible? Also interestingly, linux/arm/v5 works just fine for python:3.6 (not slim) with the example Dockerfile I provided (I tested it today). So I’m not sure what’s going on there.

At any rate, it seems that if I use the platforms that Buildx reports are supported, all should be good (assuming the base image also was built with it). At the time of writing, GitHub Actions docker/setup-buildx-action@v1 supports linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, and linux/arm/v6.

@JesseBowling I concur arm64 builds work for me as well.

I’m running builds on a ubuntu server. On that server, your examples have no problems for me with or without the PATH edit. Only when I create a docker builder in order to build for more than one platform do I run into these issues (even if I use the created builder to only build for one platform).

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name cibuilder --driver docker-container --use
docker buildx ls
docker buildx inspect --bootstrap

I tried pinning qemu docker image to 5.0.0-5 which was released 4 months ago, but that made no difference.

@fidesachates It seems to be specific to armhf (arm/v7 and arm/v8) builds. ARM64 and AMD64 build fine.

I’m not sure if I understand your question enough to give you a more solid answer than that. I can say that I’ve been primarily using this via Github Actions (i.e., https://github.com/CommunityHoneyNetwork/rdphoney/actions/runs/418797571) and it first broke 22 days ago.

The snippets I provided in the original issue came from trying to recreate the issue as simply as possible on my Macbook, which may well have had a non-default builder.