diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 7652c91cce..4f60da7a49 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1104,6 +1104,11 @@ _docker_history() { _docker_images() { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in + before) + cur="${cur##*=}" + __docker_complete_images + return + ;; dangling) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return @@ -1111,11 +1116,16 @@ _docker_images() { label) return ;; + since) + cur="${cur##*=}" + __docker_complete_images + return + ;; esac case "$prev" in --filter|-f) - COMPREPLY=( $( compgen -S = -W "dangling label" -- "$cur" ) ) + COMPREPLY=( $( compgen -S = -W "before dangling label since" -- "$cur" ) ) __docker_nospace return ;; diff --git a/contrib/completion/zsh/_docker b/contrib/completion/zsh/_docker index 2132fe8722..8ac3e7fe49 100644 --- a/contrib/completion/zsh/_docker +++ b/contrib/completion/zsh/_docker @@ -341,10 +341,13 @@ __docker_complete_images_filters() { declare -a boolean_opts opts boolean_opts=('true' 'false') - opts=('dangling' 'label') + opts=('before' 'dangling' 'label' 'since') if compset -P '*='; then case "${${words[-1]%=*}#*=}" in + (before|since) + __docker_images && ret=0 + ;; (dangling) _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 ;; diff --git a/docs/reference/commandline/images.md b/docs/reference/commandline/images.md index 9ab97684c4..b9f80980b0 100644 --- a/docs/reference/commandline/images.md +++ b/docs/reference/commandline/images.md @@ -16,7 +16,11 @@ parent = "smn_cli" -a, --all Show all images (default hides intermediate images) --digests Show digests - -f, --filter=[] Filter output based on conditions provided + -f, --filter=[] Filter output based on these conditions: + - dangling=(true|false) + - label= or label== + - before=([:tag]||) + - since=([:tag]||) --help Print usage --no-trunc Don't truncate output -q, --quiet Only show numeric IDs @@ -121,6 +125,8 @@ The currently supported filters are: * dangling (boolean - true or false) * label (`label=` or `label==`) +* before (`[:]`, `` or ``) - filters images created before given id or references +* since (`[:]`, `` or ``) - filters images created since given id or references ##### Untagged images (dangling) @@ -165,19 +171,56 @@ The following filter matches images with the `com.example.version` label regardl REPOSITORY TAG IMAGE ID CREATED SIZE match-me-1 latest eeae25ada2aa About a minute ago 188.3 MB - match-me-2 latest eeae25ada2aa About a minute ago 188.3 MB + match-me-2 latest dea752e4e117 About a minute ago 188.3 MB The following filter matches images with the `com.example.version` label with the `1.0` value. $ docker images --filter "label=com.example.version=1.0" REPOSITORY TAG IMAGE ID CREATED SIZE - match-me latest eeae25ada2aa About a minute ago 188.3 MB + match-me latest 511136ea3c5a About a minute ago 188.3 MB In this example, with the `0.1` value, it returns an empty set because no matches were found. $ docker images --filter "label=com.example.version=0.1" REPOSITORY TAG IMAGE ID CREATED SIZE +#### Before + +The `before` filter shows only images created before the image with +given id or reference. For example, having these images: + + $ docker images + REPOSITORY TAG IMAGE ID CREATED SIZE + image1 latest eeae25ada2aa 4 minutes ago 188.3 MB + image2 latest dea752e4e117 9 minutes ago 188.3 MB + image3 latest 511136ea3c5a 25 minutes ago 188.3 MB + +Filtering with `before` would give: + + $ docker images --filter "before=image1" + REPOSITORY TAG IMAGE ID CREATED SIZE + image2 latest dea752e4e117 9 minutes ago 188.3 MB + image3 latest 511136ea3c5a 25 minutes ago 188.3 MB + +#### Since + +The `since` filter shows only images created after the image with +given id or reference. For example, having these images: + + $ docker images + REPOSITORY TAG IMAGE ID CREATED SIZE + image1 latest eeae25ada2aa 4 minutes ago 188.3 MB + image2 latest dea752e4e117 9 minutes ago 188.3 MB + image3 latest 511136ea3c5a 25 minutes ago 188.3 MB + +Filtering with `since` would give: + + $ docker images --filter "since=image3" + REPOSITORY TAG IMAGE ID CREATED SIZE + image1 latest eeae25ada2aa 4 minutes ago 188.3 MB + image2 latest dea752e4e117 9 minutes ago 188.3 MB + + ## Formatting The formatting option (`--format`) will pretty print container output diff --git a/man/docker-images.1.md b/man/docker-images.1.md index 8410280a1d..fd551a58db 100644 --- a/man/docker-images.1.md +++ b/man/docker-images.1.md @@ -38,7 +38,11 @@ versions. Show image digests. The default is *false*. **-f**, **--filter**=[] - Filters the output. The dangling=true filter finds unused images. While label=com.foo=amd64 filters for images with a com.foo value of amd64. The label=com.foo filter finds images with the label com.foo of any value. + Filters the output based on these conditions: + - dangling=(true|false) - finds unused images. + - label= or label== + - before=([:tag]||) + - since=([:tag]||) **--format**="*TEMPLATE*" Pretty-print containers using a Go template.