diff --git a/cmd/podman/common/build.go b/cmd/podman/common/build.go index e6d3aa5597..100e6568d5 100644 --- a/cmd/podman/common/build.go +++ b/cmd/podman/common/build.go @@ -65,11 +65,11 @@ func DefineBuildFlags(cmd *cobra.Command, buildOpts *BuildFlagsWrapper) { // --pull flag flag := budFlags.Lookup("pull") - if err := flag.Value.Set("true"); err != nil { - logrus.Errorf("Unable to set --pull to true: %v", err) + flag.DefValue = "missing" + if err := flag.Value.Set("missing"); err != nil { + logrus.Errorf("Unable to set --pull to 'missing': %v", err) } - flag.DefValue = "true" - flag.Usage = "Always attempt to pull the image (errors are fatal)" + flag.Usage = `Pull image policy ("always/true"|"missing"|"never/false"|"newer")` flags.AddFlagSet(&budFlags) // Add the completion functions diff --git a/docs/source/markdown/podman-build.1.md.in b/docs/source/markdown/podman-build.1.md.in index cbf1e71fca..b635807ad9 100644 --- a/docs/source/markdown/podman-build.1.md.in +++ b/docs/source/markdown/podman-build.1.md.in @@ -653,7 +653,7 @@ the help of emulation provided by packages like `qemu-user-static`. #### **--pull**=*policy* -Pull image policy. The default is **always**. +Pull image policy. The default is **missing**. - **always**, **true**: 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. diff --git a/test/system/070-build.bats b/test/system/070-build.bats index d780a2e2df..56da8ef32d 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -24,6 +24,10 @@ EOF PODMAN_TIMEOUT=240 run_podman build -t build_test --format=docker $tmpdir is "$output" ".*COMMIT" "COMMIT seen in log" + # $IMAGE is preloaded, so we should never re-pull + assert "$output" !~ "Trying to pull" "Default pull policy should be 'missing'" + assert "$output" !~ "Writing manifest" "Default pull policy should be 'missing'" + run_podman run --rm build_test cat /$rand_filename is "$output" "$rand_content" "reading generated file in image"