Docker build doesn't pick TARGETARCH arg value when running on Amazon Linux 2

47 views Asked by At

I’m running docker build on an Amazon Linux 2 EC2 instance, and using TARGETARCH arg to identify the target architecture:

FROM python:3.12.1-slim-bookworm AS build

ARG TARGETARCH
RUN echo "arch is ${TARGETARCH}"

For some reason, docker build doesn’t pick the TARGETARCH value, see below:

Step 1/46 : FROM python:3.12.1-slim-bookworm AS build
 ---> 16c231298165
Step 2/46 : ARG TARGETARCH
 ---> Using cache
 ---> c34eb6f2eaf4
Step 3/46 : RUN echo "arch is ${TARGETARCH}"
 ---> Using cache
 ---> 5af08adff044

When running docker build on an Ubuntu 20.04 EC2 instance, it’s working:

#4 [build  1/16] FROM docker.io/library/python:3.12.1-slim-bookworm@sha256:a64ac5be6928c6a94f00b16e09cdf3ba3edd44452d10ffa4516a58004873573e
#4 CACHED

#5 [internal] load build context
#5 transferring context: 65B done
#5 DONE 0.0s

#6 [build  2/16] RUN echo "arch is amd64"
#6 0.193 arch is amd64
#6 DONE 0.2s

Same is working on an Amazon Linux 2023 EC2 instance. Any idea why docker build doesn’t pick up the TARGETARCH value when running on Amazon Linux 2?

0

There are 0 answers