Skip to content

Commit

Permalink
Do not pull if image domain is localhost
Browse files Browse the repository at this point in the history
With podman play kube, podman would always attempt to
pull if the image has the :latest tag. But this would
fail if the image was built locally and given latest
as the tag. Images build with podman and buildah have
localhost as the domain, so check if the domain is localhost.
If that is the case, then don't attempt a pull.

Signed-off-by: Urvashi Mohnani <[email protected]>
  • Loading branch information
umohnani8 committed Dec 7, 2020
1 parent a5ca039 commit b0707af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/source/markdown/podman-play-kube.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Ideally the input file would be one created by Podman (see podman-generate-kube(

Note: HostPath volume types created by play kube will be given an SELinux private label (Z)

Note: If the `:latest` tag is used, Podman will attempt to pull the image from a registry. If the image was built locally with Podman or Buildah, it will have `localhost` as the domain, in that case, Podman will use the image from the local store even if it has the `:latest` tag.

## OPTIONS

#### **--authfile**=*path*
Expand Down
4 changes: 3 additions & 1 deletion pkg/domain/infra/abi/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
return nil, errors.Wrapf(err, "Failed to parse image %q", container.Image)
}
// In kube, if the image is tagged with latest, it should always pull
// but if the domain is localhost, that means the image was built locally
// so do not attempt a pull.
if tagged, isTagged := named.(reference.NamedTagged); isTagged {
if tagged.Tag() == image.LatestTag {
if tagged.Tag() == image.LatestTag && reference.Domain(named) != image.DefaultLocalRegistry {
pullPolicy = util.PullImageAlways
}
}
Expand Down

0 comments on commit b0707af

Please sign in to comment.