How can a Docker image target arm64 if its base image does not?

20 Views Asked by At

I am using an image that was not built for linux/arm64:

docker pull --platform linux/arm64 mcr.microsoft.com/powershell:lts-7.2-alpine-3.17

image with reference mcr.microsoft.com/powershell:lts-7.2-alpine-3.17 was found but does not match the specified platform: wanted linux/arm64, actual: linux/amd64

And indeed, if I inspect the image, its architecture is amd64

docker image inspect --format '{{.Architecture}}' mcr.microsoft.com/powershell:lts-7.2-alpine-3.17

amd64

But if I use the image as a base image in my Dockerfile...

FROM mcr.microsoft.com/powershell:lts-7.2-alpine-3.17

...and then build it...

docker build --platform linux/arm64  --tag test .

...and then inspect the image, its architecture is arm64

docker image inspect --format '{{.Architecture}}' test:latest

amd64

So does the architecture of an image only reflect the value of the --platform argument at the time of build, and not the 'intrinsic' architecture?

0

There are 0 best solutions below