Skip to content

Commit c59d1df

Browse files
Merge pull request #20124 from vrothberg/build-docs
podman build: correct default pull policy
2 parents ca1cd02 + 59e295f commit c59d1df

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

cmd/podman/common/build.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ func DefineBuildFlags(cmd *cobra.Command, buildOpts *BuildFlagsWrapper) {
6565

6666
// --pull flag
6767
flag := budFlags.Lookup("pull")
68-
if err := flag.Value.Set("true"); err != nil {
69-
logrus.Errorf("Unable to set --pull to true: %v", err)
68+
flag.DefValue = "missing"
69+
if err := flag.Value.Set("missing"); err != nil {
70+
logrus.Errorf("Unable to set --pull to 'missing': %v", err)
7071
}
71-
flag.DefValue = "true"
72-
flag.Usage = "Always attempt to pull the image (errors are fatal)"
72+
flag.Usage = `Pull image policy ("always/true"|"missing"|"never/false"|"newer")`
7373
flags.AddFlagSet(&budFlags)
7474

7575
// Add the completion functions

docs/source/markdown/podman-build.1.md.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ the help of emulation provided by packages like `qemu-user-static`.
653653

654654
#### **--pull**=*policy*
655655

656-
Pull image policy. The default is **always**.
656+
Pull image policy. The default is **missing**.
657657

658658
- **always**, **true**: Always pull the image and throw an error if the pull fails.
659659
- **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.

test/system/070-build.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ EOF
2424
PODMAN_TIMEOUT=240 run_podman build -t build_test --format=docker $tmpdir
2525
is "$output" ".*COMMIT" "COMMIT seen in log"
2626

27+
# $IMAGE is preloaded, so we should never re-pull
28+
assert "$output" !~ "Trying to pull" "Default pull policy should be 'missing'"
29+
assert "$output" !~ "Writing manifest" "Default pull policy should be 'missing'"
30+
2731
run_podman run --rm build_test cat /$rand_filename
2832
is "$output" "$rand_content" "reading generated file in image"
2933

0 commit comments

Comments
 (0)