Revital Eres
Revital Eres

Reputation: 263

Dockerfile FROM image when using docker --platform flag

When using --platform flag does the base image is automatically adjusted to be based on the desired platform? for example when the target is linux/arm64 then a base image with tag suffix aarch64 will be used to build the image regardless of the base image written in the Dockerfile.

Upvotes: 0

Views: 83

Answers (1)

The DevOps Dude
The DevOps Dude

Reputation: 1872

When you use the --platform flag in Docker, it doesn't automatically change the base image in your Dockerfile to fit the specified platform. Instead, this flag tells Docker which platform (like Linux on ARM64) you want to build the image for.

If the base image in your Dockerfile supports multiple platforms, Docker will try to use the version that matches your specified platform. If the base image doesn't support your platform, the build might fail unless you specifically choose a version of the image that does.

I’ll suggest the following to make sure your build works:

  • Use images that support multiple platforms if possible.
  • Clearly mention the platform in your Dockerfile if needed.
  • Check that everything you add to your Dockerfile works on the target platform.

Upvotes: 0

Related Questions