Repository navigation
Conversation
|
Hi, thanks for addressing this! From your description above, I wasn't able to know if there is a way to get a machine-readable result, other than parsing the logs? If not, this would be really useful in scripts. |
|
Thanks for taking a look, @jmlord! Good point: at the moment the result is only reported in the I'll add a $ docker pull --dry-run --format json alpine
{"Reference":"docker.io/library/alpine:latest","Digest":"sha256:...","Status":"up-to-date"}
$ docker pull --dry-run --format '{{.Status}}' alpine
up-to-datewith |
Add a --dry-run option to "docker pull" that reports whether pulling an
image would download a newer version, without pulling anything.
The CLI asks the daemon to resolve the reference to a digest in the
registry (DistributionInspect) and compares it against the digests of
the local image, printing the same "Digest:" / "Status:" lines as a
regular pull:
$ docker pull --dry-run debian
Digest: sha256:3f1d6c...
Status: Image is up to date for docker.io/library/debian:latest
docker.io/library/debian:latest
This makes it possible to detect available updates in automation without
downloading the image.
The --dry-run option cannot be combined with --all-tags.
fixes docker#6059
Signed-off-by: Raphael <rdgabmomoh@gmail.com>
|
Pushed an update: |
Description
Adds a
--dry-runoption todocker pullthat reports whether pulling an image would download a newer version, without pulling anything.The CLI asks the daemon to resolve the reference to a digest in the registry (
DistributionInspect, i.e. a manifest HEAD lookup) and compares it against the digests recorded on the local image (RepoDigests). Output uses the sameDigest:/Status:lines as a regular pull, so existing tooling that parses pull output keeps working:Other statuses:
Status: A newer image is available for <ref>— the registry digest differs from the local image's digests.Status: Image <ref> is not available locally and would be pulled— no local image with this reference.Design notes:
--dry-runcannot be combined with--all-tags(digest comparison is per-reference).--quietsuppresses theDigest:/Status:lines, printing only the reference, mirroring regular pull behavior./distribution/{name}/jsonendpoint, which already performs the registry HEAD request with the daemon's registry configuration (including insecure registries).0as long as the check itself succeeded; the result is communicated through theStatus:line.Docs (markdown + man page) and bash/zsh/fish completions are updated, and unit tests cover the up-to-date, newer-available, not-present-locally, quiet, and invalid-flag-combination cases.
How to verify