Error: docker buildx on x86_64 for building multiarch--x86_64, arm64
Asked Answered
M

3

7

I just make multarch images by using buildx
When running docker buildx build --platform linux/amd64,linux/arm64 -t maskertim/zookeeper-demo .

Error Message

The Error as following:

------
 > [linux/arm64 3/5] RUN curl "https://archive.apache.org/dist/kafka/2.8.0/kafka_2.13-2.8.0.tgz"    -o /tmp/kafka/kafka.tgz &&  mkdir /kafka && cd /kafka &&    tar -xzvf /tmp/kafka/kafka.tgz --strip 1:
#8 0.915   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#8 0.916                                  Dload  Upload   Total   Spent    Left  Speed
100 68.0M  100 68.0M    0     0   936k      0  0:01:14  0:01:14 --:--:-- 3475k
#8 75.45 tar: Child returned status 1
#8 75.45 tar: Error is not recoverable: exiting now
------
dockerfile:9
--------------------
   8 |     
   9 | >>> RUN curl "https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz" \
  10 | >>>  -o /tmp/kafka/kafka.tgz && \
  11 | >>>  mkdir /kafka && cd /kafka && \
  12 | >>>  tar -xzvf /tmp/kafka/kafka.tgz --strip 1
  13 |     
--------------------
error: failed to solve: process "/dev/.buildkit_qemu_emulator /bin/sh -c curl \"https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz\" \t-o /tmp/kafka/kafka.tgz && \tmkdir /kafka && cd /kafka && \ttar -xzvf /tmp/kafka/kafka.tgz --strip 1" did not complete successfully: exit code: 2

Dockerfile

And this is my dockerfile:

FROM openjdk:11.0.12-jre-buster

ENV KAFKA_VERSION 2.8.0
ENV SCALA_VERSION 2.13
RUN mkdir /tmp/kafka && \
    apt-get update && \
    apt-get install -y curl

RUN curl "https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz" \
    -o /tmp/kafka/kafka.tgz && \
    mkdir /kafka && cd /kafka && \
    tar -xzvf /tmp/kafka/kafka.tgz --strip 1

COPY start-zookeeper.sh /usr/bin
RUN chmod +x /usr/bin/start-zookeeper.sh

CMD ["start-zookeeper.sh"]

What happens? I have no idea why to occur this error and no way to solve it.

Monstrosity answered 21/9, 2021 at 16:26 Comment(1)
I had a similar issue building on ARM64 and was able to work around it by separating the decompression step (bzip2 in my case) from the untar step. Base image was Alpine 3.15. I don't know why tar was failing.Delorsedelos
D
5

Unzip it first:

gzip -d /tmp/kafka/kafka.tgz

And after that untar it with:

tar xpf /tmp/kafka/kafka.tar
Danielledaniels answered 20/4, 2022 at 14:17 Comment(0)
A
0

I had the same problem and discovered https://stackoverflow.com/a/71143883

Running docker run --rm --privileged multiarch/qemu-user-static --reset -p yes allowed me to keep the decompression step in the tar command

Antitrust answered 20/7, 2022 at 1:56 Comment(0)
H
0

I think the problem is related to tar or more specific one of its child processes is failing to untar or unzip because of a missing dependency, which seems not to be present in the qemu_emulator that buildx uses.

I ended up using the ADD command in the dockerfile instead of RUN tar, which has that functionality built in.

Heall answered 26/9, 2022 at 21:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.