0

I want to built a docker image on my Intel laptop. The image will be deployed on both x86/x64 and arm64 hosts. The docker file uses ubuntu:20.04 base image. I tried building the image with following command:

docker buildx build . --no-cache --progress plain --platform linux/arm64/v8,linux/amd64 -t mytag

But it fails with error:

#10 [linux/arm64  3/17] RUN apt update &&     apt install -y --no-install-recommends software-properties-common &&     add-apt-repository -y ppa:ubuntu-toolchain-r/test &&     add-apt-repository -y "deb http://security.ubuntu.com/ubuntu xenial-security main" &&     add-apt-repository -y ppa:deadsnakes/ppa  &&     apt-get update &&     apt-get install -y --no-install-recommends     sudo     usbutils     libcanberra-gtk3-module ...*
#10 191.3 Reading package lists...
#10 195.6 E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/main/binary-arm64/Packages  404  Not Found [IP: 185.125.190.39 80]
#10 195.6 E: Some index files failed to download. They have been ignored, or old ones used instead.
#10 ERROR: process "/bin/sh -c apt update &&     apt install -y --no-install-recommends software-properties-common &&     add-apt-repository -y ppa:ubuntu-toolchain-r/test &&     add-apt-repository -y \"deb http://security.ubuntu.com/ubuntu xenial-security main\" &&     add-apt-repository -y ppa:deadsnakes/ppa  &&     apt-get update &&     apt-get install -y --no-install-recommends     sudo     usbutils     libcanberra-gtk3-module ..." did not complete successfully: exit code: 100

Referring to this answer, I added following lines to my Dockerfile:

## add arm64 architecture
RUN apt-get update
RUN dpkg --add-architecture arm64

## arch-qualify the current repositories
RUN sed -i "s/deb h/deb [arch=amd64] h/g" /etc/apt/sources.list

## add arm64's repos
RUN echo "# arm64 repositories" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal main restricted" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal universe" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-updates universe" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal multiverse" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-updates multiverse" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-security main restricted" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-security universe" >> /etc/apt/sources.list
RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-security multiverse" >> /etc/apt/sources.list

But now it gives me following error:

#23 19.23 E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal/main/binary-amd64/Packages  404  Not Found [IP: 185.125.190.39 80]
#23 19.23 E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-updates/multiverse/binary-amd64/Packages  404  Not Found [IP: 185.125.190.39 80]
#23 19.23 E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-backports/main/binary-amd64/Packages  404  Not Found [IP: 185.125.190.39 80]
#23 19.23 E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-security/multiverse/binary-amd64/Packages  404  Not Found [IP: 185.125.190.39 80]
#23 19.23 E: Some index files failed to download. They have been ignored, or old ones used instead.

#23 19.23 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:3 and /etc/apt/sources.list:51
#23 19.23 W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:3 and /etc/apt/sources.list:51
#23 19.24 W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:14 and /etc/apt/sources.list:53
#23 19.24 W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:24 and /etc/apt/sources.list:55
#23 19.24 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:8 and /etc/apt/sources.list:52
#23 19.24 W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:8 and /etc/apt/sources.list:52
#23 19.24 W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:16 and /etc/apt/sources.list:54
#23 19.24 W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:26 and /etc/apt/sources.list:56
#23 19.24 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:34 and /etc/apt/sources.list:57
#23 19.24 W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:34 and /etc/apt/sources.list:57
#23 19.24 W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:34 and /etc/apt/sources.list:57
#23 19.24 W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:34 and /etc/apt/sources.list:57
#23 19.24 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:44 and /etc/apt/sources.list:58
#23 19.24 W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:44 and /etc/apt/sources.list:58
#23 19.24 W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:46 and /etc/apt/sources.list:59
#23 19.24 W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:60
#23 ERROR: process "/bin/sh -c apt-get update" did not complete successfully: exit code: 100

#9 [linux/amd64  2/31] RUN apt-get update
#9 39.27 Get:16 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3553 kB]
#9 CANCELED
------
 > [linux/arm64 16/31] RUN apt-get update:
19.24 W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:16 and /etc/apt/sources.list:54
19.24 W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:26 and /etc/apt/sources.list:56
19.24 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:34 and /etc/apt/sources.list:57
19.24 W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:34 and /etc/apt/sources.list:57
19.24 W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:34 and /etc/apt/sources.list:57
19.24 W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:34 and /etc/apt/sources.list:57
19.24 W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:44 and /etc/apt/sources.list:58
19.24 W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:44 and /etc/apt/sources.list:58
19.24 W: Target Packages (universe/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:46 and /etc/apt/sources.list:59
19.24 W: Target Packages (multiverse/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:60
------
WARNING: No output specified with 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
Dockerfile:31
--------------------
  29 |     RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-security multiverse" >> /etc/apt/sources.list
  30 |     
  31 | >>> RUN apt-get update
  32 |     # Set environment variables to avoid interactive prompts during installation
  33 |     ENV DEBIAN_FRONTEND=noninteractive
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update" did not complete successfully: exit code: 100

What I am missing here?

Update 1

I forgot to tell that I was able to successfully build the image for the same architecture as my laptop (x86/x64 or amd64) with command:

docker build . --no-cache --progress plain -t mytag

The issue started when I tried to build for arm64 / multi-architecture.

Update 2

I tried by commenting lines corresponding to 404 error:

# RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal main restricted" >> /etc/apt/sources.list   
# RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-updates multiverse" >> /etc/apt/sources.list
# RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse" >> /etc/apt/sources.list
# RUN echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-security multiverse" >> /etc/apt/sources.list

But still same error.

This was expected, as the 404 is occuring for amd64 packages and not arm64 packages:

#23 19.23 E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal/main/binary-amd64/Packages  404  Not Found [IP: 185.125.190.39 80]
#23 19.23 E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-updates/multiverse/binary-amd64/Packages  404  Not Found [IP: 185.125.190.39 80]
#23 19.23 E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-backports/main/binary-amd64/Packages  404  Not Found [IP: 185.125.190.39 80]
#23 19.23 E: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-security/multiverse/binary-amd64/Packages  404  Not Found [IP: 185.125.190.39 80]

But I am guessing why it is failing for amd64 packages as it used to successfully build the image before I added changes for arm64.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.