Bug 1216189

Summary: Podman --platform triggers registry selection
Product: [openSUSE] openSUSE Tumbleweed Reporter: Alexandre Vicenzi <alexandre.vicenzi>
Component: ContainersAssignee: Containers Team <containers-bugowner>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: dcermak
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Alexandre Vicenzi 2023-10-12 15:17:09 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.
Comment 1 Dan Čermák 2023-10-13 05:52:04 UTC
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.
Comment 2 Alexandre Vicenzi 2023-10-13 07:55:16 UTC
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.
Comment 3 Dan Čermák 2023-10-13 08:13:43 UTC
(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).