Skip to content

Podman does not pull base image by default #21450

Open
@bdabelow

Description

@bdabelow

Describe the bug
Packaging docker_image() with podman backend does not pull the base image (in the FROM clause) if it does not already exist locally.
This will cause the build to fail:

23:43:48.89 [ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal

ProcessExecutionFailure: Process 'Building docker image my-image:latest' failed with exit code 125.
stdout:
STEP 1/3: FROM docker.io/alpine/k8s:1.28.13

stderr:
Error: creating build container: docker.io/alpine/k8s:1.28.13: image not known

Pants version
2.22.0

OS
Linux

Additional info
Can be worked around by setting pull=True on docker_image(), however this will always pull the base image, not only if not existing locally.

Probable cause is differences off --pull between docker and podman

man docker-build:

       --pull true|false
          Always attempt to pull a newer version of the image. The default is false.

man podman-build:

   --pull=policy
       Pull image policy. The default is missing.

              • always: Always pull the image and throw an error if the pull fails.

              • missing: Only pull the image when it does not exist in the local containers storage.  Throw an error if no image is found and the pull fails.

              • never: Never pull the image but use the one from the local containers storage.  Throw an error when no image is found.

              • newer:  Pull if the image on the registry is newer than the one in the local containers storage.  An image is considered to be newer when the digests are different.  Comparing the time stamps is prone to errors.  Pull
                errors are suppressed if a local image was found.

From my understanding podman's missing matches the behaviour of docker's false, podman's newer matches docker's true.

However without pull=True, pants uses --pull=False for both. Apparently though unspecified, False is mapped to never in podman, causing the above error.

I will try to come up with a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions