Bugzilla – Bug 1216189
Podman --platform triggers registry selection
Last modified: 2023-10-13 08:13:43 UTC
The argument --platform in podman run always triggers image selection even if the image was built locally and is available. For example, build any container, such as a hello world: podman build --platform=linux/amd64 -t hello-rust -f Dockerfile Once I run the following command: podman run --rm --platform=linux/amd64 hello-rust I get the following message: ? Please select an image: registry.opensuse.org/hello-rust:latest registry.suse.com/hello-rust:latest docker.io/library/hello-rust:latest Once I select a registry it does not attempt to download, it just runs the local image. The image is available locally, but the registry selection always pops up if --platform is set. The command below never asks the registry if the image is available: podman run --rm hello-rust Both run commands should behave equally.
This is a "fallout" of https://github.com/containers/podman/issues/10682 with a bit more explanation in https://github.com/containers/podman/blob/5afa949a43d3e07d6fd4d61456d23c768787cbc6/vendor/github.com/containers/common/libimage/pull.go#L519 tl;dr; If you specify a platform, then you implicitly tell podman that your local image arch might not be trusted and it *will* try to pull it from a registry, hence creating the prompt.
Thanks for the explanation Dan. This is an odd behavior because the image has an OS and architecture set, if you inspect the image you can see that it matches the platform I set. I guess this issue is less annoying if you have only one registry because it won't pop registry selection.
(In reply to Alexandre Vicenzi from comment #2) > This is an odd behavior because the image has an OS and architecture set, if > you inspect the image you can see that it matches the platform I set. Yes, but apparently images sometimes set this value wrong. The code path you are suffering from has been added to protect you from exactly this case (it is discussed to quite some extend in the linked issue if you care for the gory details).