github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/docs/reference/commandline/images.md (about)

     1  ---
     2  title: "images"
     3  description: "The images command description and usage"
     4  keywords: "list, docker, images"
     5  ---
     6  
     7  # images
     8  
     9  ```markdown
    10  Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]
    11  
    12  List images
    13  
    14  Options:
    15    -a, --all             Show all images (default hides intermediate images)
    16        --digests         Show digests
    17    -f, --filter value    Filter output based on conditions provided (default [])
    18                          - dangling=(true|false)
    19                          - label=<key> or label=<key>=<value>
    20                          - before=(<image-name>[:tag]|<image-id>|<image@digest>)
    21                          - since=(<image-name>[:tag]|<image-id>|<image@digest>)
    22                          - reference=(pattern of an image reference)
    23        --format string   Pretty-print images using a Go template
    24        --help            Print usage
    25        --no-trunc        Don't truncate output
    26    -q, --quiet           Only show image IDs
    27  ```
    28  
    29  ## Description
    30  
    31  The default `docker images` will show all top level
    32  images, their repository and tags, and their size.
    33  
    34  Docker images have intermediate layers that increase reusability,
    35  decrease disk usage, and speed up `docker build` by
    36  allowing each step to be cached. These intermediate layers are not shown
    37  by default.
    38  
    39  The `SIZE` is the cumulative space taken up by the image and all
    40  its parent images. This is also the disk space used by the contents of the
    41  Tar file created when you `docker save` an image.
    42  
    43  An image will be listed more than once if it has multiple repository names
    44  or tags. This single image (identifiable by its matching `IMAGE ID`)
    45  uses up the `SIZE` listed only once.
    46  
    47  ## Examples
    48  
    49  ### List the most recently created images
    50  
    51  ```bash
    52  $ docker images
    53  
    54  REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    55  <none>                    <none>              77af4d6b9913        19 hours ago        1.089 GB
    56  committ                   latest              b6fa739cedf5        19 hours ago        1.089 GB
    57  <none>                    <none>              78a85c484f71        19 hours ago        1.089 GB
    58  docker                    latest              30557a29d5ab        20 hours ago        1.089 GB
    59  <none>                    <none>              5ed6274db6ce        24 hours ago        1.089 GB
    60  postgres                  9                   746b819f315e        4 days ago          213.4 MB
    61  postgres                  9.3                 746b819f315e        4 days ago          213.4 MB
    62  postgres                  9.3.5               746b819f315e        4 days ago          213.4 MB
    63  postgres                  latest              746b819f315e        4 days ago          213.4 MB
    64  ```
    65  
    66  ### List images by name and tag
    67  
    68  The `docker images` command takes an optional `[REPOSITORY[:TAG]]` argument
    69  that restricts the list to images that match the argument. If you specify
    70  `REPOSITORY`but no `TAG`, the `docker images` command lists all images in the
    71  given repository.
    72  
    73  For example, to list all images in the "java" repository, run this command :
    74  
    75  ```bash
    76  $ docker images java
    77  
    78  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    79  java                8                   308e519aac60        6 days ago          824.5 MB
    80  java                7                   493d82594c15        3 months ago        656.3 MB
    81  java                latest              2711b1d6f3aa        5 months ago        603.9 MB
    82  ```
    83  
    84  The `[REPOSITORY[:TAG]]` value must be an "exact match". This means that, for example,
    85  `docker images jav` does not match the image `java`.
    86  
    87  If both `REPOSITORY` and `TAG` are provided, only images matching that
    88  repository and tag are listed.  To find all local images in the "java"
    89  repository with tag "8" you can use:
    90  
    91  ```bash
    92  $ docker images java:8
    93  
    94  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    95  java                8                   308e519aac60        6 days ago          824.5 MB
    96  ```
    97  
    98  If nothing matches `REPOSITORY[:TAG]`, the list is empty.
    99  
   100  ```bash
   101  $ docker images java:0
   102  
   103  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
   104  ```
   105  
   106  ### List the full length image IDs
   107  
   108  ```bash
   109  $ docker images --no-trunc
   110  
   111  REPOSITORY                    TAG                 IMAGE ID                                                                  CREATED             SIZE
   112  <none>                        <none>              sha256:77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182   19 hours ago        1.089 GB
   113  committest                    latest              sha256:b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f   19 hours ago        1.089 GB
   114  <none>                        <none>              sha256:78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921   19 hours ago        1.089 GB
   115  docker                        latest              sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4   20 hours ago        1.089 GB
   116  <none>                        <none>              sha256:0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5   20 hours ago        1.089 GB
   117  <none>                        <none>              sha256:18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b   22 hours ago        1.082 GB
   118  <none>                        <none>              sha256:f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a   23 hours ago        1.089 GB
   119  tryout                        latest              sha256:2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074   23 hours ago        131.5 MB
   120  <none>                        <none>              sha256:5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df   24 hours ago        1.089 GB
   121  ```
   122  
   123  ### List image digests
   124  
   125  Images that use the v2 or later format have a content-addressable identifier
   126  called a `digest`. As long as the input used to generate the image is
   127  unchanged, the digest value is predictable. To list image digest values, use
   128  the `--digests` flag:
   129  
   130  ```bash
   131  $ docker images --digests
   132  REPOSITORY                         TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
   133  localhost:5000/test/busybox        <none>              sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf   4986bf8c1536        9 weeks ago         2.43 MB
   134  ```
   135  
   136  When pushing or pulling to a 2.0 registry, the `push` or `pull` command
   137  output includes the image digest. You can `pull` using a digest value. You can
   138  also reference by digest in `create`, `run`, and `rmi` commands, as well as the
   139  `FROM` image reference in a Dockerfile.
   140  
   141  ### Filtering
   142  
   143  The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
   144  than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
   145  
   146  The currently supported filters are:
   147  
   148  * dangling (boolean - true or false)
   149  * label (`label=<key>` or `label=<key>=<value>`)
   150  * before (`<image-name>[:<tag>]`,  `<image id>` or `<image@digest>`) - filter images created before given id or references
   151  * since (`<image-name>[:<tag>]`,  `<image id>` or `<image@digest>`) - filter images created since given id or references
   152  * reference (pattern of an image reference) - filter images whose reference matches the specified pattern
   153  
   154  #### Show untagged images (dangling)
   155  
   156  ```bash
   157  $ docker images --filter "dangling=true"
   158  
   159  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
   160  <none>              <none>              8abc22fbb042        4 weeks ago         0 B
   161  <none>              <none>              48e5f45168b9        4 weeks ago         2.489 MB
   162  <none>              <none>              bf747efa0e2f        4 weeks ago         0 B
   163  <none>              <none>              980fe10e5736        12 weeks ago        101.4 MB
   164  <none>              <none>              dea752e4e117        12 weeks ago        101.4 MB
   165  <none>              <none>              511136ea3c5a        8 months ago        0 B
   166  ```
   167  
   168  This will display untagged images that are the leaves of the images tree (not
   169  intermediary layers). These images occur when a new build of an image takes the
   170  `repo:tag` away from the image ID, leaving it as `<none>:<none>` or untagged.
   171  A warning will be issued if trying to remove an image when a container is presently
   172  using it. By having this flag it allows for batch cleanup.
   173  
   174  You can use this in conjunction with `docker rmi ...`:
   175  
   176  ```bash
   177  $ docker rmi $(docker images -f "dangling=true" -q)
   178  
   179  8abc22fbb042
   180  48e5f45168b9
   181  bf747efa0e2f
   182  980fe10e5736
   183  dea752e4e117
   184  511136ea3c5a
   185  ```
   186  
   187  Docker warns you if any containers exist that are using these untagged images.
   188  
   189  
   190  #### Show images with a given label
   191  
   192  The `label` filter matches images based on the presence of a `label` alone or a `label` and a
   193  value.
   194  
   195  The following filter matches images with the `com.example.version` label regardless of its value.
   196  
   197  ```bash
   198  $ docker images --filter "label=com.example.version"
   199  
   200  REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
   201  match-me-1          latest              eeae25ada2aa        About a minute ago   188.3 MB
   202  match-me-2          latest              dea752e4e117        About a minute ago   188.3 MB
   203  ```
   204  
   205  The following filter matches images with the `com.example.version` label with the `1.0` value.
   206  
   207  ```bash
   208  $ docker images --filter "label=com.example.version=1.0"
   209  
   210  REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
   211  match-me            latest              511136ea3c5a        About a minute ago   188.3 MB
   212  ```
   213  
   214  In this example, with the `0.1` value, it returns an empty set because no matches were found.
   215  
   216  ```bash
   217  $ docker images --filter "label=com.example.version=0.1"
   218  REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
   219  ```
   220  
   221  #### Filter images by time
   222  
   223  The `before` filter shows only images created before the image with
   224  given id or reference. For example, having these images:
   225  
   226  ```bash
   227  $ docker images
   228  
   229  REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
   230  image1              latest              eeae25ada2aa        4 minutes ago        188.3 MB
   231  image2              latest              dea752e4e117        9 minutes ago        188.3 MB
   232  image3              latest              511136ea3c5a        25 minutes ago       188.3 MB
   233  ```
   234  
   235  Filtering with `before` would give:
   236  
   237  ```bash
   238  $ docker images --filter "before=image1"
   239  
   240  REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
   241  image2              latest              dea752e4e117        9 minutes ago        188.3 MB
   242  image3              latest              511136ea3c5a        25 minutes ago       188.3 MB
   243  ```
   244  
   245  Filtering with `since` would give:
   246  
   247  ```bash
   248  $ docker images --filter "since=image3"
   249  REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
   250  image1              latest              eeae25ada2aa        4 minutes ago        188.3 MB
   251  image2              latest              dea752e4e117        9 minutes ago        188.3 MB
   252  ```
   253  
   254  #### Filter images by reference
   255  
   256  The `reference` filter shows only images whose reference matches
   257  the specified pattern.
   258  
   259  ```bash
   260  $ docker images
   261  
   262  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
   263  busybox             latest              e02e811dd08f        5 weeks ago         1.09 MB
   264  busybox             uclibc              e02e811dd08f        5 weeks ago         1.09 MB
   265  busybox             musl                733eb3059dce        5 weeks ago         1.21 MB
   266  busybox             glibc               21c16b6787c6        5 weeks ago         4.19 MB
   267  ```
   268  
   269  Filtering with `reference` would give:
   270  
   271  ```bash
   272  $ docker images --filter=reference='busy*:*libc'
   273  
   274  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
   275  busybox             uclibc              e02e811dd08f        5 weeks ago         1.09 MB
   276  busybox             glibc               21c16b6787c6        5 weeks ago         4.19 MB
   277  ```
   278  
   279  Filtering with multiple `reference` would give, either match A or B:
   280  
   281  ```bash
   282  $ docker images --filter=reference='busy*:uclibc' --filter=reference='busy*:glibc'
   283  
   284  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
   285  busybox             uclibc              e02e811dd08f        5 weeks ago         1.09 MB
   286  busybox             glibc               21c16b6787c6        5 weeks ago         4.19 MB
   287  ```
   288  
   289  ### Format the output
   290  
   291  The formatting option (`--format`) will pretty print container output
   292  using a Go template.
   293  
   294  Valid placeholders for the Go template are listed below:
   295  
   296  | Placeholder | Description|
   297  | ---- | ---- |
   298  | `.ID` | Image ID |
   299  | `.Repository` | Image repository |
   300  | `.Tag` | Image tag |
   301  | `.Digest` | Image digest |
   302  | `.CreatedSince` | Elapsed time since the image was created |
   303  | `.CreatedAt` | Time when the image was created |
   304  | `.Size` | Image disk size |
   305  
   306  When using the `--format` option, the `image` command will either
   307  output the data exactly as the template declares or, when using the
   308  `table` directive, will include column headers as well.
   309  
   310  The following example uses a template without headers and outputs the
   311  `ID` and `Repository` entries separated by a colon (`:`) for all images:
   312  
   313  ```bash
   314  $ docker images --format "{{.ID}}: {{.Repository}}"
   315  
   316  77af4d6b9913: <none>
   317  b6fa739cedf5: committ
   318  78a85c484f71: <none>
   319  30557a29d5ab: docker
   320  5ed6274db6ce: <none>
   321  746b819f315e: postgres
   322  746b819f315e: postgres
   323  746b819f315e: postgres
   324  746b819f315e: postgres
   325  ```
   326  
   327  To list all images with their repository and tag in a table format you
   328  can use:
   329  
   330  ```bash
   331  $ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
   332  
   333  IMAGE ID            REPOSITORY                TAG
   334  77af4d6b9913        <none>                    <none>
   335  b6fa739cedf5        committ                   latest
   336  78a85c484f71        <none>                    <none>
   337  30557a29d5ab        docker                    latest
   338  5ed6274db6ce        <none>                    <none>
   339  746b819f315e        postgres                  9
   340  746b819f315e        postgres                  9.3
   341  746b819f315e        postgres                  9.3.5
   342  746b819f315e        postgres                  latest
   343  ```