I'm building container images using Docker and Podman, and wanted to provide the consuming engineer with a way to specify the architecture e.g. amd64 or s390x etc. of a dependent download from within the Dockerfile itself.
The Dockerfile was hard-coded to pull down the amd64 version; which doesn't work too well on my IBM Z s390x boxes.
Therefore, I set an argument within the Dockerfile, via the ARG parameter, which I left defaulted to amd64 but which allowed the engineer to then over-ride that argument when they run the docker build or podman build command.
This over-ride works via the --build-arg option of the build command.
However, I wanted to be even more lazy and allow the OS upon which the command was being run to set the architecture.
I started with the following: -
docker build --build-arg=$(uname -p) -f Dockerfile .
which worked on my IBM Z box ( running Ubuntu 18.04.06 ).
However, on my x86-64 box, running Ubuntu 20.04.5, this failed because, it transpires, uname -p returns x86_64 rather than amd64.
However, StackExchange came to my rescue : -
Note that architecture-independent packages use all there, and you’d have to know that in advance.