Merge pull request #25308 from jasdeepbhalla/fix/pull-no-cache-clarify-best-practices

docs: clarify distinct purposes of --pull and --no-cache flags
This commit is contained in:
Jasdeep Singh Bhalla
2026-06-15 05:35:34 -07:00
committed by GitHub
parent 5c562fed32
commit 338ecb5235
@@ -114,9 +114,11 @@ $ docker build --no-cache -t my-image:my-tag .
```
This gets the latest available versions of dependencies from package
managers like `apt-get` or `npm`. However, `--no-cache` doesn't pull a
fresh base image - it only prevents reusing cached layers. For a
completely fresh build with the latest base image, combine both flags:
managers like `apt-get` or `npm`. It does not pull a fresh base image —
for that, use `--pull`.
The two flags serve distinct purposes and can be combined. Use both
together to get a fresh base image and re-execute all build steps:
```console
$ docker build --pull --no-cache -t my-image:my-tag .