Skip to contentSkip to conversation

automation: set architecture in docker files

PATCH In review Roger Pau Monne 3 participants 6 messages Nov 13, 2023 – Nov 14, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 automation: set architecture in docker files

Pass the desired architecture of the image in the FROM instruction if the image is possibly multi-platform.

This allows using the x86 Dockerfiles on OS X on arm64 hardware.

No functional change intended.

---
I haven't touched the Yocto dockerfile because I'm not sure how it's used.

---
 automation/build/alpine/3.18.dockerfile               | 2 +-
 automation/build/archlinux/current-riscv64.dockerfile | 2 +-
 automation/build/archlinux/current.dockerfile         | 2 +-
 automation/build/centos/7.dockerfile                  | 2 +-
 automation/build/debian/bookworm.dockerfile           | 2 +-
 automation/build/debian/bullseye-ppc64le.dockerfile   | 2 +-
 automation/build/debian/buster-gcc-ibt.dockerfile     | 2 +-
 automation/build/debian/jessie.dockerfile             | 2 +-
 automation/build/debian/stretch.dockerfile            | 2 +-
 automation/build/fedora/29.dockerfile                 | 2 +-
 automation/build/suse/opensuse-leap.dockerfile        | 2 +-
 automation/build/suse/opensuse-tumbleweed.dockerfile  | 2 +-
 automation/build/ubuntu/bionic.dockerfile             | 2 +-
 automation/build/ubuntu/focal.dockerfile              | 2 +-
 automation/build/ubuntu/trusty.dockerfile             | 2 +-
 automation/build/ubuntu/xenial-xilinx.dockerfile      | 2 +-
 automation/build/ubuntu/xenial.dockerfile             | 2 +-
 17 files changed, 17 insertions(+), 17 deletions(-)
automation/build/alpine/3.18.dockerfile +1 -1
index 5d2a69a06010..4ae9cb5e9e30 100644
@@ -1,4 +1,4 @@
-FROM alpine:3.18
+FROM --platform=linux/amd64 alpine:3.18
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/archlinux/current-riscv64.dockerfile +1 -1
index abf8e7bf0b88..af75b5c720ce 100644
@@ -1,4 +1,4 @@
-FROM archlinux
+FROM --platform=linux/amd64 archlinux
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/archlinux/current.dockerfile +1 -1
index 47e79637a4a6..d974a1434fd5 100644
@@ -1,4 +1,4 @@
-FROM archlinux:base-devel
+FROM --platform=linux/amd64 archlinux:base-devel
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/centos/7.dockerfile +1 -1
index 69dcefb2f011..ab450f0b3a0e 100644
@@ -1,4 +1,4 @@
-FROM centos:7
+FROM --platform=linux/amd64 centos:7
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/debian/bookworm.dockerfile +1 -1
index ae008c8d46e5..ac87778b3972 100644
@@ -1,4 +1,4 @@
-FROM debian:bookworm
+FROM --platform=linux/amd64 debian:bookworm
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/debian/bullseye-ppc64le.dockerfile +1 -1
index 4de8458445ae..6fdfb6bc2b40 100644
@@ -1,4 +1,4 @@
-FROM debian:bullseye-slim
+FROM --platform=linux/amd64 debian:bullseye-slim
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/debian/buster-gcc-ibt.dockerfile +1 -1
index 96ab4fe8a2f1..4328c109b72b 100644
@@ -1,4 +1,4 @@
-FROM debian:buster-slim AS builder
+FROM --platform=linux/amd64 debian:buster-slim AS builder
 
 ENV DEBIAN_FRONTEND=noninteractive
 ENV USER root
automation/build/debian/jessie.dockerfile +1 -1
index 63b2c1e5b771..db0962953c9a 100644
@@ -1,4 +1,4 @@
-FROM debian/eol:jessie
+FROM --platform=linux/amd64 debian/eol:jessie
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/debian/stretch.dockerfile +1 -1
index 1af6c691f8f4..9f6c146f032c 100644
@@ -1,4 +1,4 @@
-FROM debian:stretch
+FROM --platform=linux/amd64 debian:stretch
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/fedora/29.dockerfile +1 -1
index e55b06a4517e..42a87ce6c84b 100644
@@ -1,4 +1,4 @@
-FROM fedora:29
+FROM --platform=linux/amd64 fedora:29
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/suse/opensuse-leap.dockerfile +1 -1
index 7010b71acaa0..e1ec38a41445 100644
@@ -1,4 +1,4 @@
-FROM opensuse/leap
+FROM --platform=linux/amd64 opensuse/leap
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/suse/opensuse-tumbleweed.dockerfile +1 -1
index 959e1f6939f0..38f6fda2ff1b 100644
@@ -1,4 +1,4 @@
-FROM opensuse/tumbleweed
+FROM --platform=linux/amd64 opensuse/tumbleweed
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/bionic.dockerfile +1 -1
index e15f54431efb..77d7f933860c 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:18.04
+FROM --platform=linux/amd64 ubuntu:18.04
 LABEL maintainer.name="The Xen Project " \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/focal.dockerfile +1 -1
index e3d11194ee2f..30a9b8e84ffe 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:20.04
+FROM --platform=linux/amd64 ubuntu:20.04
 LABEL maintainer.name="The Xen Project " \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/trusty.dockerfile +1 -1
index 22e294c20cac..0d33578c4e1d 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:14.04
+FROM --platform=linux/amd64 ubuntu:14.04
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/xenial-xilinx.dockerfile +1 -1
index 5f7087135213..49f27b322995 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:16.04
+FROM --platform=linux/amd64 ubuntu:16.04
 LABEL maintainer.name="The Xen Project " \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/xenial.dockerfile +1 -1
index 2d2ba3e31f63..e8035434f804 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:16.04
+FROM --platform=linux/amd64 ubuntu:16.04
 LABEL maintainer.name="The Xen Project " \
       maintainer.email="[email protected]"
 
Signature · 1 line
2.42.0
#1 lore raw
Quoted 8 lines · Roger Pau Monne

Pass the desired architecture of the image in the FROM instruction if the image is possibly multi-platform.

This allows using the x86 Dockerfiles on OS X on arm64 hardware.

No functional change intended.

Although I am not opposed to this change, so far we have been using:
arm64v8/alpine:3.18

for x86 it is not specified but it would be:
amd64/alpine:3.18

Two options:
1) we add amd64/ everywhere and leave the arm containers alone
2) we change all containers, including the arm containers, to use the --platform option

I don't think is a good idea to have 2 different ways to specify the architecture for x86 and arm containers

Quoted 195 lines

---
I haven't touched the Yocto dockerfile because I'm not sure how it's used.

---
 automation/build/alpine/3.18.dockerfile               | 2 +-
 automation/build/archlinux/current-riscv64.dockerfile | 2 +-
 automation/build/archlinux/current.dockerfile         | 2 +-
 automation/build/centos/7.dockerfile                  | 2 +-
 automation/build/debian/bookworm.dockerfile           | 2 +-
 automation/build/debian/bullseye-ppc64le.dockerfile   | 2 +-
 automation/build/debian/buster-gcc-ibt.dockerfile     | 2 +-
 automation/build/debian/jessie.dockerfile             | 2 +-
 automation/build/debian/stretch.dockerfile            | 2 +-
 automation/build/fedora/29.dockerfile                 | 2 +-
 automation/build/suse/opensuse-leap.dockerfile        | 2 +-
 automation/build/suse/opensuse-tumbleweed.dockerfile  | 2 +-
 automation/build/ubuntu/bionic.dockerfile             | 2 +-
 automation/build/ubuntu/focal.dockerfile              | 2 +-
 automation/build/ubuntu/trusty.dockerfile             | 2 +-
 automation/build/ubuntu/xenial-xilinx.dockerfile      | 2 +-
 automation/build/ubuntu/xenial.dockerfile             | 2 +-
 17 files changed, 17 insertions(+), 17 deletions(-)
automation/build/alpine/3.18.dockerfile +1 -1
index 5d2a69a06010..4ae9cb5e9e30 100644
@@ -1,4 +1,4 @@
-FROM alpine:3.18
+FROM --platform=linux/amd64 alpine:3.18
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/archlinux/current-riscv64.dockerfile +1 -1
index abf8e7bf0b88..af75b5c720ce 100644
@@ -1,4 +1,4 @@
-FROM archlinux
+FROM --platform=linux/amd64 archlinux
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/archlinux/current.dockerfile +1 -1
index 47e79637a4a6..d974a1434fd5 100644
@@ -1,4 +1,4 @@
-FROM archlinux:base-devel
+FROM --platform=linux/amd64 archlinux:base-devel
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/centos/7.dockerfile +1 -1
index 69dcefb2f011..ab450f0b3a0e 100644
@@ -1,4 +1,4 @@
-FROM centos:7
+FROM --platform=linux/amd64 centos:7
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/debian/bookworm.dockerfile +1 -1
index ae008c8d46e5..ac87778b3972 100644
@@ -1,4 +1,4 @@
-FROM debian:bookworm
+FROM --platform=linux/amd64 debian:bookworm
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/debian/bullseye-ppc64le.dockerfile +1 -1
index 4de8458445ae..6fdfb6bc2b40 100644
@@ -1,4 +1,4 @@
-FROM debian:bullseye-slim
+FROM --platform=linux/amd64 debian:bullseye-slim
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/debian/buster-gcc-ibt.dockerfile +1 -1
index 96ab4fe8a2f1..4328c109b72b 100644
@@ -1,4 +1,4 @@
-FROM debian:buster-slim AS builder
+FROM --platform=linux/amd64 debian:buster-slim AS builder
 
 ENV DEBIAN_FRONTEND=noninteractive
 ENV USER root
automation/build/debian/jessie.dockerfile +1 -1
index 63b2c1e5b771..db0962953c9a 100644
@@ -1,4 +1,4 @@
-FROM debian/eol:jessie
+FROM --platform=linux/amd64 debian/eol:jessie
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/debian/stretch.dockerfile +1 -1
index 1af6c691f8f4..9f6c146f032c 100644
@@ -1,4 +1,4 @@
-FROM debian:stretch
+FROM --platform=linux/amd64 debian:stretch
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/fedora/29.dockerfile +1 -1
index e55b06a4517e..42a87ce6c84b 100644
@@ -1,4 +1,4 @@
-FROM fedora:29
+FROM --platform=linux/amd64 fedora:29
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/suse/opensuse-leap.dockerfile +1 -1
index 7010b71acaa0..e1ec38a41445 100644
@@ -1,4 +1,4 @@
-FROM opensuse/leap
+FROM --platform=linux/amd64 opensuse/leap
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/suse/opensuse-tumbleweed.dockerfile +1 -1
index 959e1f6939f0..38f6fda2ff1b 100644
@@ -1,4 +1,4 @@
-FROM opensuse/tumbleweed
+FROM --platform=linux/amd64 opensuse/tumbleweed
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/bionic.dockerfile +1 -1
index e15f54431efb..77d7f933860c 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:18.04
+FROM --platform=linux/amd64 ubuntu:18.04
 LABEL maintainer.name="The Xen Project " \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/focal.dockerfile +1 -1
index e3d11194ee2f..30a9b8e84ffe 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:20.04
+FROM --platform=linux/amd64 ubuntu:20.04
 LABEL maintainer.name="The Xen Project " \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/trusty.dockerfile +1 -1
index 22e294c20cac..0d33578c4e1d 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:14.04
+FROM --platform=linux/amd64 ubuntu:14.04
 LABEL maintainer.name="The Xen Project" \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/xenial-xilinx.dockerfile +1 -1
index 5f7087135213..49f27b322995 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:16.04
+FROM --platform=linux/amd64 ubuntu:16.04
 LABEL maintainer.name="The Xen Project " \
       maintainer.email="[email protected]"
 
automation/build/ubuntu/xenial.dockerfile +1 -1
index 2d2ba3e31f63..e8035434f804 100644
@@ -1,4 +1,4 @@
-FROM ubuntu:16.04
+FROM --platform=linux/amd64 ubuntu:16.04
 LABEL maintainer.name="The Xen Project " \
       maintainer.email="[email protected]"
 
Signature · 1 line
2.42.0
#2 lore raw
Quoted 16 lines · Stefano Stabellini
Quoted 8 lines · Roger Pau Monne

Pass the desired architecture of the image in the FROM instruction if the image is possibly multi-platform.

This allows using the x86 Dockerfiles on OS X on arm64 hardware.

No functional change intended.

Although I am not opposed to this change, so far we have been using:
arm64v8/alpine:3.18

for x86 it is not specified but it would be:
amd64/alpine:3.18

Quoted 7 lines

Two options:
1) we add amd64/ everywhere and leave the arm containers alone
2) we change all containers, including the arm containers, to use the --platform option

I don't think is a good idea to have 2 different ways to specify the architecture for x86 and arm containers

I'm not an expert on this, but attempting to use (2):

-FROM arm64v8/alpine:3.18
+FROM --platform=linux/arm64v8 alpine:3.18

Does not work for me:

% make -C automation/build alpine/3.18-arm64v8
docker build --pull -t registry.gitlab.com/xen-project/xen/alpine:3.18-arm64v8 -f alpine/3.18-arm64v8.dockerfile alpine
[+] Building 1.4s (3/3) FINISHED docker:desktop-linux

 => [internal] load .dockerignore                                                                 0.0s
 => => transferring context: 2B                                                                   0.0s
 => [internal] load build definition from 3.18-arm64v8.dockerfile                                 0.0s
 => => transferring dockerfile: 818B                                                              0.0s
 => ERROR [internal] load metadata for docker.io/library/alpine:3.18                              1.4s

------

Quoted 1 line

[internal] load metadata for docker.io/library/alpine:3.18:

------
3.18-arm64v8.dockerfile:1
--------------------

   1 | >>> FROM --platform=linux/arm64v8 alpine:3.18
   2 |     LABEL maintainer.name="The Xen Project" \
   3 |           maintainer.email="[email protected]"

--------------------
ERROR: failed to solve: alpine:3.18: no match for platform in manifest sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978: not found
make: *** [alpine/3.18-arm64v8] Error 1

That's why I've left the prefixed images alone.

I could prefix the x86 images with amd64/ if that's preferred, I didn't try that option, as the Docker manual suggested using --platform.

Thanks, Roger.

#3 lore raw
Quoted 52 lines · Roger Pau Monné
Quoted 16 lines · Stefano Stabellini
Quoted 8 lines · Roger Pau Monne

Pass the desired architecture of the image in the FROM instruction if the image is possibly multi-platform.

This allows using the x86 Dockerfiles on OS X on arm64 hardware.

No functional change intended.

Although I am not opposed to this change, so far we have been using:
arm64v8/alpine:3.18

for x86 it is not specified but it would be:
amd64/alpine:3.18

Quoted 7 lines

Two options:
1) we add amd64/ everywhere and leave the arm containers alone
2) we change all containers, including the arm containers, to use the --platform option

I don't think is a good idea to have 2 different ways to specify the architecture for x86 and arm containers

I'm not an expert on this, but attempting to use (2):

(quoted diff) +1 -1
-FROM arm64v8/alpine:3.18
+FROM --platform=linux/arm64v8 alpine:3.18

Does not work for me:

% make -C automation/build alpine/3.18-arm64v8
docker build --pull -t registry.gitlab.com/xen-project/xen/alpine:3.18-arm64v8 -f alpine/3.18-arm64v8.dockerfile alpine
[+] Building 1.4s (3/3) FINISHED docker:desktop-linux

 => [internal] load .dockerignore                                                                 0.0s
 => => transferring context: 2B                                                                   0.0s
 => [internal] load build definition from 3.18-arm64v8.dockerfile                                 0.0s
 => => transferring dockerfile: 818B                                                              0.0s
 => ERROR [internal] load metadata for docker.io/library/alpine:3.18                              1.4s

------

Quoted 1 line

[internal] load metadata for docker.io/library/alpine:3.18:

------
3.18-arm64v8.dockerfile:1
--------------------

   1 | >>> FROM --platform=linux/arm64v8 alpine:3.18
   2 |     LABEL maintainer.name="The Xen Project" \
   3 |           maintainer.email="[email protected]"

--------------------
ERROR: failed to solve: alpine:3.18: no match for platform in manifest sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978: not found
make: *** [alpine/3.18-arm64v8] Error 1

Quoted 5 lines

That's why I've left the prefixed images alone.

I could prefix the x86 images with amd64/ if that's preferred, I didn't try that option, as the Docker manual suggested using --platform.

So a few things to know, "--platform=linux/amd64" just select a different build of one container. For example, for the "alpine" containers, you can see all the different builds available on the docker hub, here a few links:
- Official Docker, Alpine images, home:
https://hub.docker.com/_/alpine
- The different builds:
https://hub.docker.com/_/alpine/tags

So, for amd64v8, you probably want --platform=linux/arm64/v8

Then, they are per-architecture repository that make it easier to deal with foreign architecture, and probably maintained by a different community. e.g. for alpine arm64v8:

    https://hub.docker.com/r/arm64v8/alpine/

Those provide a build for a single architecture.

Sometime, you actually need to "--platform=*" to select a particular architecture, like I did for "jessie-i386.dockerfile".

One thing I've notice when using --platform is that, if for example I use the container "--platform=linux/amd64 alpine:3" then "--platform=linux/arm/v6 alpine:3"; later when I only specify "alpine:3", it's going to be the armv6, and I think docker is going to complain if I try tu use "--platform=linux/amd64 alpine:3" without "docker pull" first (or I guess docker build --pull).

Hope that help.

So I guess using containers "amd64/*" or "arm64v8/*" is fine, but sometime will need to use "--platform=*".

Cheers,

Signature · 1 line
Anthony PERARD
#4 lore raw
Quoted 68 lines · Anthony PERARD
Quoted 52 lines · Roger Pau Monné
Quoted 16 lines · Stefano Stabellini
Quoted 8 lines · Roger Pau Monne

Pass the desired architecture of the image in the FROM instruction if the image is possibly multi-platform.

This allows using the x86 Dockerfiles on OS X on arm64 hardware.

No functional change intended.

Although I am not opposed to this change, so far we have been using:
arm64v8/alpine:3.18

for x86 it is not specified but it would be:
amd64/alpine:3.18

Quoted 7 lines

Two options:
1) we add amd64/ everywhere and leave the arm containers alone
2) we change all containers, including the arm containers, to use the --platform option

I don't think is a good idea to have 2 different ways to specify the architecture for x86 and arm containers

I'm not an expert on this, but attempting to use (2):

(quoted diff) +1 -1
-FROM arm64v8/alpine:3.18
+FROM --platform=linux/arm64v8 alpine:3.18

Does not work for me:

% make -C automation/build alpine/3.18-arm64v8
docker build --pull -t registry.gitlab.com/xen-project/xen/alpine:3.18-arm64v8 -f alpine/3.18-arm64v8.dockerfile alpine
[+] Building 1.4s (3/3) FINISHED docker:desktop-linux

 => [internal] load .dockerignore                                                                 0.0s
 => => transferring context: 2B                                                                   0.0s
 => [internal] load build definition from 3.18-arm64v8.dockerfile                                 0.0s
 => => transferring dockerfile: 818B                                                              0.0s
 => ERROR [internal] load metadata for docker.io/library/alpine:3.18                              1.4s

------

Quoted 1 line

[internal] load metadata for docker.io/library/alpine:3.18:

------
3.18-arm64v8.dockerfile:1
--------------------

   1 | >>> FROM --platform=linux/arm64v8 alpine:3.18
   2 |     LABEL maintainer.name="The Xen Project" \
   3 |           maintainer.email="[email protected]"

--------------------
ERROR: failed to solve: alpine:3.18: no match for platform in manifest sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978: not found
make: *** [alpine/3.18-arm64v8] Error 1

Quoted 5 lines

That's why I've left the prefixed images alone.

I could prefix the x86 images with amd64/ if that's preferred, I didn't try that option, as the Docker manual suggested using --platform.

So a few things to know, "--platform=linux/amd64" just select a different build of one container. For example, for the "alpine" containers, you can see all the different builds available on the docker hub, here a few links:
- Official Docker, Alpine images, home:
https://hub.docker.com/_/alpine
- The different builds:
https://hub.docker.com/_/alpine/tags

Quoted 1 line

So, for amd64v8, you probably want --platform=linux/arm64/v8

Interesting, I guess I was looking at an outdated documentation that stated the tag as arm64v8 instead of arm64/v8.

Quoted 7 lines

Then, they are per-architecture repository that make it easier to deal with foreign architecture, and probably maintained by a different community. e.g. for alpine arm64v8:

    https://hub.docker.com/r/arm64v8/alpine/

Those provide a build for a single architecture.

Right, so those two are not actually the same image. I wonder whether we would want to uniformly switch to using --platform when possible, in order to make sure we are using the same (multi arch) image to avoid surprises.

Quoted 13 lines

Sometime, you actually need to "--platform=*" to select a particular architecture, like I did for "jessie-i386.dockerfile".

One thing I've notice when using --platform is that, if for example I use the container "--platform=linux/amd64 alpine:3" then "--platform=linux/arm/v6 alpine:3"; later when I only specify "alpine:3", it's going to be the armv6, and I think docker is going to complain if I try tu use "--platform=linux/amd64 alpine:3" without "docker pull" first (or I guess docker build --pull).

Quoted 4 lines

Hope that help.

So I guess using containers "amd64/*" or "arm64v8/*" is fine, but sometime will need to use "--platform=*".

My take is that it's better to use --platform when possible, as then all platforms share the same image, and the contents of the image should be more consistent.

I guess we could see about switching some of the image that currently use a prefix (like the Alpine one) in order to instead use --platform and share the same image. I wouldn't want to do it in this patch however, as the change presented here should be non-functional, while switching to the multi arch image might introduce changes.

Thanks, Roger.

#5 lore raw
Quoted 109 lines · Roger Pau Monné
Quoted 68 lines · Anthony PERARD
Quoted 52 lines · Roger Pau Monné
Quoted 16 lines · Stefano Stabellini
Quoted 8 lines · Roger Pau Monne

Pass the desired architecture of the image in the FROM instruction if the image is possibly multi-platform.

This allows using the x86 Dockerfiles on OS X on arm64 hardware.

No functional change intended.

Although I am not opposed to this change, so far we have been using:
arm64v8/alpine:3.18

for x86 it is not specified but it would be:
amd64/alpine:3.18

Quoted 7 lines

Two options:
1) we add amd64/ everywhere and leave the arm containers alone
2) we change all containers, including the arm containers, to use the --platform option

I don't think is a good idea to have 2 different ways to specify the architecture for x86 and arm containers

I'm not an expert on this, but attempting to use (2):

(quoted diff) +1 -1
-FROM arm64v8/alpine:3.18
+FROM --platform=linux/arm64v8 alpine:3.18

Does not work for me:

% make -C automation/build alpine/3.18-arm64v8
docker build --pull -t registry.gitlab.com/xen-project/xen/alpine:3.18-arm64v8 -f alpine/3.18-arm64v8.dockerfile alpine
[+] Building 1.4s (3/3) FINISHED docker:desktop-linux

 => [internal] load .dockerignore                                                                 0.0s
 => => transferring context: 2B                                                                   0.0s
 => [internal] load build definition from 3.18-arm64v8.dockerfile                                 0.0s
 => => transferring dockerfile: 818B                                                              0.0s
 => ERROR [internal] load metadata for docker.io/library/alpine:3.18                              1.4s

------

Quoted 1 line

[internal] load metadata for docker.io/library/alpine:3.18:

------
3.18-arm64v8.dockerfile:1
--------------------

   1 | >>> FROM --platform=linux/arm64v8 alpine:3.18
   2 |     LABEL maintainer.name="The Xen Project" \
   3 |           maintainer.email="[email protected]"

--------------------
ERROR: failed to solve: alpine:3.18: no match for platform in manifest sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978: not found
make: *** [alpine/3.18-arm64v8] Error 1

Quoted 5 lines

That's why I've left the prefixed images alone.

I could prefix the x86 images with amd64/ if that's preferred, I didn't try that option, as the Docker manual suggested using --platform.

So a few things to know, "--platform=linux/amd64" just select a different build of one container. For example, for the "alpine" containers, you can see all the different builds available on the docker hub, here a few links:
- Official Docker, Alpine images, home:
https://hub.docker.com/_/alpine
- The different builds:
https://hub.docker.com/_/alpine/tags

Quoted 1 line

So, for amd64v8, you probably want --platform=linux/arm64/v8

Interesting, I guess I was looking at an outdated documentation that stated the tag as arm64v8 instead of arm64/v8.

Quoted 7 lines

Then, they are per-architecture repository that make it easier to deal with foreign architecture, and probably maintained by a different community. e.g. for alpine arm64v8:

    https://hub.docker.com/r/arm64v8/alpine/

Those provide a build for a single architecture.

Right, so those two are not actually the same image. I wonder whether we would want to uniformly switch to using --platform when possible, in order to make sure we are using the same (multi arch) image to avoid surprises.

Quoted 13 lines

Sometime, you actually need to "--platform=*" to select a particular architecture, like I did for "jessie-i386.dockerfile".

One thing I've notice when using --platform is that, if for example I use the container "--platform=linux/amd64 alpine:3" then "--platform=linux/arm/v6 alpine:3"; later when I only specify "alpine:3", it's going to be the armv6, and I think docker is going to complain if I try tu use "--platform=linux/amd64 alpine:3" without "docker pull" first (or I guess docker build --pull).

Quoted 4 lines

Hope that help.

So I guess using containers "amd64/*" or "arm64v8/*" is fine, but sometime will need to use "--platform=*".

My take is that it's better to use --platform when possible, as then all platforms share the same image, and the contents of the image should be more consistent.

Quoted 5 lines

I guess we could see about switching some of the image that currently use a prefix (like the Alpine one) in order to instead use --platform and share the same image. I wouldn't want to do it in this patch however, as the change presented here should be non-functional, while switching to the multi arch image might introduce changes.

I am OK with any way forward as long as we are consistent across architectures.

If you don't want to change the existing arm64v8 prefixes, I am fine with that, but then I would ask you to use the amd64 prefix not to break consistency (do not use --platform).

After that, if you prefer to use --platform, I am totally fine with that too and it can be a follow-up patch changing the containers of both architectures.