Ubuntu 24.04 arm64 image compile error

Hi, I use something like:

# image: Ubuntu 24.04 ARM64
FROM --platform=linux/arm64 ubuntu:24.04


ENV DEBIAN_FRONTEND=noninteractive


RUN apt-get update && apt-get install -y \
    curl wget vim git ca-certificates \
    && rm -rf /var/lib/apt/lists/*


WORKDIR /app

COPY . /app

CMD ["/bin/bash"]

and run docker build --platform=linux/arm64 -t my-ubuntu24.04-arm64 ., and get:

# docker build --network=host -t my-image .
[+] Building 1.6s (6/8)                                         docker:default
 => [internal] load build definition from Dockerfile                      0.0s
 => => transferring dockerfile: 468B                                      0.0s
 => WARN: FromPlatformFlagConstDisallowed: FROM --platform flag should n  0.0s
 => [internal] load metadata for docker.io/library/ubuntu:24.04           1.4s
 => [internal] load .dockerignore                                         0.0s
 => => transferring context: 2B                                           0.0s
 => CACHED [1/4] FROM docker.io/library/ubuntu:24.04@sha256:a08e551cb338  0.0s
 => [internal] load build context                                         0.0s
 => => transferring context: 1.03kB                                       0.0s
 => ERROR [2/4] RUN apt-get update && apt-get install -y     curl wget v  0.1s
------
 > [2/4] RUN apt-get update && apt-get install -y     curl wget vim git ca-certificates     && rm -rf /var/lib/apt/lists/*:
0.071 exec /bin/sh: exec format error
------

 1 warning found (use docker --debug to expand):
 - FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/arm64" (line 2)
Dockerfile:8
--------------------
   7 |     
   8 | >>> RUN apt-get update && apt-get install -y \
   9 | >>>     curl wget vim git ca-certificates \
  10 | >>>     && rm -rf /var/lib/apt/lists/*
  11 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y     curl wget vim git ca-certificates     && rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 255

Please help me to fix this, thank you so much.
I can build it successfully almost 2 weeks ago, I don’t know what’s wrong right now.

The exec format error usually refers to executables for wrong platforms, but I could not reproduce it.

I would try building without cache first.

docker build --platform=linux/arm64 --no-cache -t my-ubuntu24.04-arm64

If it doesn’t help, we usually need the following information to understand the issue:

  1. What platform are you using? Windows, Linux or macOS? Which version of the operating systems? In case of Linux, which distribution?

  2. How did you install Docker? Sharing the platform almost answers it, but only almost. Direct links to the followed guide can be useful.

  3. On debian based Linux, the following commands can give us some idea and recognize incorrectly installed Docker:

    docker info
    docker version
    

    Review the output before sharing and remove confidential data if any appears (public IP for example)

    dpkg -l 'docker*' | grep '^ii'
    snap list docker
    

Thanks a lot @rimelek . Add ‘–no-cache’ works for me now.

Then I assume the wrong architecture was used once and somehow that was still loaded from cache. If it is true, now you should be able to rebuild the image with cache as well. I hope the issue will not come back again.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.