2

I'm trying to create a multi-arch container based on ubuntu 20.04. Docker build fails on apt update after the new architecture is added. This is my docker file so far:

# base image
FROM ubuntu:20.04

create user

RUN useradd -rm -d /home/embed -s /bin/bash -g root -G sudo -u 1001 embed RUN mkdir -p /home/embed/software RUN mkdir -p /home/embed/data

symlink python3 to python

RUN ln -s /usr/bin/python3 /usr/bin/python

install arm64 cross-compilation toolchain

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

After it reaches apt-get update, I get the following output:

Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Ign:5 http://security.ubuntu.com/ubuntu focal-security/main arm64 Packages
Ign:6 http://security.ubuntu.com/ubuntu focal-security/restricted arm64 Packages
Ign:7 http://security.ubuntu.com/ubuntu focal-security/universe arm64 Packages
Ign:5 http://security.ubuntu.com/ubuntu focal-security/main arm64 Packages
Ign:6 http://security.ubuntu.com/ubuntu focal-security/restricted arm64 Packages
Ign:7 http://security.ubuntu.com/ubuntu focal-security/universe arm64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu focal/multiverse arm64 Packages
Ign:5 http://security.ubuntu.com/ubuntu focal-security/main arm64 Packages
Ign:6 http://security.ubuntu.com/ubuntu focal-security/restricted arm64 Packages
Ign:7 http://security.ubuntu.com/ubuntu focal-security/universe arm64 Packages
Ign:9 http://archive.ubuntu.com/ubuntu focal/restricted arm64 Packages
Ign:10 http://archive.ubuntu.com/ubuntu focal/universe arm64 Packages
Ign:11 http://archive.ubuntu.com/ubuntu focal/main arm64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu focal/multiverse arm64 Packages
Ign:9 http://archive.ubuntu.com/ubuntu focal/restricted arm64 Packages
Ign:10 http://archive.ubuntu.com/ubuntu focal/universe arm64 Packages
Ign:5 http://security.ubuntu.com/ubuntu focal-security/main arm64 Packages
Ign:6 http://security.ubuntu.com/ubuntu focal-security/restricted arm64 Packages
Ign:7 http://security.ubuntu.com/ubuntu focal-security/universe arm64 Packages
Ign:5 http://security.ubuntu.com/ubuntu focal-security/main arm64 Packages
Ign:11 http://archive.ubuntu.com/ubuntu focal/main arm64 Packages
Ign:12 http://archive.ubuntu.com/ubuntu focal-updates/universe arm64 Packages
Ign:13 http://archive.ubuntu.com/ubuntu focal-updates/main arm64 Packages
Ign:14 http://archive.ubuntu.com/ubuntu focal-updates/multiverse arm64 Packages
Ign:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted arm64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu focal/multiverse arm64 Packages
Ign:9 http://archive.ubuntu.com/ubuntu focal/restricted arm64 Packages
Ign:6 http://security.ubuntu.com/ubuntu focal-security/restricted arm64 Packages
Ign:7 http://security.ubuntu.com/ubuntu focal-security/universe arm64 Packages
Err:5 http://security.ubuntu.com/ubuntu focal-security/main arm64 Packages
  404  Not Found [IP: 91.189.88.142 80]
Ign:6 http://security.ubuntu.com/ubuntu focal-security/restricted arm64 Packages
Ign:10 http://archive.ubuntu.com/ubuntu focal/universe arm64 Packages
Ign:11 http://archive.ubuntu.com/ubuntu focal/main arm64 Packages
Ign:12 http://archive.ubuntu.com/ubuntu focal-updates/universe arm64 Packages
Ign:13 http://archive.ubuntu.com/ubuntu focal-updates/main arm64 Packages
Ign:14 http://archive.ubuntu.com/ubuntu focal-updates/multiverse arm64 Packages
Ign:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted arm64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu focal/multiverse arm64 Packages
Ign:9 http://archive.ubuntu.com/ubuntu focal/restricted arm64 Packages
Ign:16 http://archive.ubuntu.com/ubuntu focal-backports/universe arm64 Packages
Ign:10 http://archive.ubuntu.com/ubuntu focal/universe arm64 Packages
Ign:11 http://archive.ubuntu.com/ubuntu focal/main arm64 Packages
Ign:12 http://archive.ubuntu.com/ubuntu focal-updates/universe arm64 Packages
Ign:13 http://archive.ubuntu.com/ubuntu focal-updates/main arm64 Packages
Ign:14 http://archive.ubuntu.com/ubuntu focal-updates/multiverse arm64 Packages
Ign:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted arm64 Packages
Ign:7 http://security.ubuntu.com/ubuntu focal-security/universe arm64 Packages
Ign:8 http://archive.ubuntu.com/ubuntu focal/multiverse arm64 Packages
Ign:9 http://archive.ubuntu.com/ubuntu focal/restricted arm64 Packages
Ign:16 http://archive.ubuntu.com/ubuntu focal-backports/universe arm64 Packages
Ign:10 http://archive.ubuntu.com/ubuntu focal/universe arm64 Packages
Ign:11 http://archive.ubuntu.com/ubuntu focal/main arm64 Packages
Ign:12 http://archive.ubuntu.com/ubuntu focal-updates/universe arm64 Packages
Ign:13 http://archive.ubuntu.com/ubuntu focal-updates/main arm64 Packages
Ign:14 http://archive.ubuntu.com/ubuntu focal-updates/multiverse arm64 Packages
Ign:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted arm64 Packages
Err:8 http://archive.ubuntu.com/ubuntu focal/multiverse arm64 Packages
  404  Not Found [IP: 91.189.88.142 80]
Ign:9 http://archive.ubuntu.com/ubuntu focal/restricted arm64 Packages
Ign:16 http://archive.ubuntu.com/ubuntu focal-backports/universe arm64 Packages
Ign:10 http://archive.ubuntu.com/ubuntu focal/universe arm64 Packages
Ign:11 http://archive.ubuntu.com/ubuntu focal/main arm64 Packages
Ign:12 http://archive.ubuntu.com/ubuntu focal-updates/universe arm64 Packages
Ign:13 http://archive.ubuntu.com/ubuntu focal-updates/main arm64 Packages
Ign:14 http://archive.ubuntu.com/ubuntu focal-updates/multiverse arm64 Packages
Ign:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted arm64 Packages
Ign:16 http://archive.ubuntu.com/ubuntu focal-backports/universe arm64 Packages
Err:12 http://archive.ubuntu.com/ubuntu focal-updates/universe arm64 Packages
  404  Not Found [IP: 91.189.88.142 80]
Ign:13 http://archive.ubuntu.com/ubuntu focal-updates/main arm64 Packages
Ign:14 http://archive.ubuntu.com/ubuntu focal-updates/multiverse arm64 Packages
Ign:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted arm64 Packages
Ign:16 http://archive.ubuntu.com/ubuntu focal-backports/universe arm64 Packages
Err:16 http://archive.ubuntu.com/ubuntu focal-backports/universe arm64 Packages
  404  Not Found [IP: 91.189.88.142 80]
Reading package lists...
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/main/binary-arm64/Packages  404  Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/multiverse/binary-arm64/Packages  404  Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/universe/binary-arm64/Packages  404  Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/universe/binary-arm64/Packages  404  Not Found [IP: 91.189.88.142 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c apt-get update' returned a non-zero code: 100

It seems that all arm64 repositories are either ignored or not found. I found this question that has the exact same problem, but no solution is provided.

Do I have to arch-qualify all the apt sources before doing an apt-update like this answer says? Is there a more automatic way that suits building a docker image?

Thanks in advance

M47
  • 161
  • 1
    You're using the wrong archive URLs. arm64 exists on ports.ubuntu.com not the main archive.u.c – Thomas Ward Jan 13 '21 at 14:58
  • @ThomasWard I realize that. I was wondering if there's a clean/correct way of doing it rather than manually arch qualifying the old ones. – M47 Jan 13 '21 at 16:56

1 Answers1

3

I still don't know if there's a better way of doing this but I basically did what's done here, but for 20.04. The Dockerfile is now:

# base image
FROM ubuntu:20.04

...

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

RUN apt-get update ...

M47
  • 161