github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/rmi.md (about)

     1  ---
     2  title: "rmi"
     3  description: "The rmi command description and usage"
     4  keywords: "remove, image, Docker"
     5  ---
     6  
     7  <!-- This file is maintained within the docker/cli GitHub
     8       repository at https://github.com/docker/cli/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # rmi
    17  
    18  ```markdown
    19  Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]
    20  
    21  Remove one or more images
    22  
    23  Options:
    24    -f, --force      Force removal of the image
    25        --help       Print usage
    26        --no-prune   Do not delete untagged parents
    27  ```
    28  
    29  ## Examples
    30  
    31  You can remove an image using its short or long ID, its tag, or its digest. If
    32  an image has one or more tags referencing it, you must remove all of them before
    33  the image is removed. Digest references are removed automatically when an image
    34  is removed by tag.
    35  
    36  ```bash
    37  $ docker images
    38  
    39  REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    40  test1                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    41  test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    42  test2                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    43  
    44  $ docker rmi fd484f19954f
    45  
    46  Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
    47  2013/12/11 05:47:16 Error: failed to remove one or more images
    48  
    49  $ docker rmi test1
    50  
    51  Untagged: test1:latest
    52  
    53  $ docker rmi test2
    54  
    55  Untagged: test2:latest
    56  
    57  
    58  $ docker images
    59  
    60  REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    61  test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    62  
    63  $ docker rmi test
    64  
    65  Untagged: test:latest
    66  Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
    67  ```
    68  
    69  If you use the `-f` flag and specify the image's short or long ID, then this
    70  command untags and removes all images that match the specified ID.
    71  
    72  ```bash
    73  $ docker images
    74  
    75  REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    76  test1                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    77  test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    78  test2                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    79  
    80  $ docker rmi -f fd484f19954f
    81  
    82  Untagged: test1:latest
    83  Untagged: test:latest
    84  Untagged: test2:latest
    85  Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
    86  ```
    87  
    88  An image pulled by digest has no tag associated with it:
    89  
    90  ```bash
    91  $ docker images --digests
    92  
    93  REPOSITORY                     TAG       DIGEST                                                                    IMAGE ID        CREATED         SIZE
    94  localhost:5000/test/busybox    <none>    sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf   4986bf8c1536    9 weeks ago     2.43 MB
    95  ```
    96  
    97  To remove an image using its digest:
    98  
    99  ```bash
   100  $ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
   101  Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
   102  Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
   103  Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
   104  Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
   105  ```