github.com/itscaro/cli@v0.0.0-20190705081621-c9db0fe93829/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  ## Description
    30  
    31  Removes (and un-tags) one or more images from the host node. If an image has
    32  multiple tags, using this command with the tag as a parameter only removes the
    33  tag. If the tag is the only one for the image, both the image and the tag are
    34  removed.
    35  
    36  This does not remove images from a registry. You cannot remove an image of a
    37  running container unless you use the `-f` option. To see all images on a host
    38  use the [`docker image ls`](images.md) command.
    39  
    40  ## Examples
    41  
    42  You can remove an image using its short or long ID, its tag, or its digest. If
    43  an image has one or more tags referencing it, you must remove all of them before
    44  the image is removed. Digest references are removed automatically when an image
    45  is removed by tag.
    46  
    47  ```bash
    48  $ docker images
    49  
    50  REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    51  test1                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    52  test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    53  test2                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    54  
    55  $ docker rmi fd484f19954f
    56  
    57  Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
    58  2013/12/11 05:47:16 Error: failed to remove one or more images
    59  
    60  $ docker rmi test1:latest
    61  
    62  Untagged: test1:latest
    63  
    64  $ docker rmi test2:latest
    65  
    66  Untagged: test2:latest
    67  
    68  
    69  $ docker images
    70  
    71  REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    72  test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    73  
    74  $ docker rmi test:latest
    75  
    76  Untagged: test:latest
    77  Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
    78  ```
    79  
    80  If you use the `-f` flag and specify the image's short or long ID, then this
    81  command untags and removes all images that match the specified ID.
    82  
    83  ```bash
    84  $ docker images
    85  
    86  REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    87  test1                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    88  test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    89  test2                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
    90  
    91  $ docker rmi -f fd484f19954f
    92  
    93  Untagged: test1:latest
    94  Untagged: test:latest
    95  Untagged: test2:latest
    96  Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
    97  ```
    98  
    99  An image pulled by digest has no tag associated with it:
   100  
   101  ```bash
   102  $ docker images --digests
   103  
   104  REPOSITORY                     TAG       DIGEST                                                                    IMAGE ID        CREATED         SIZE
   105  localhost:5000/test/busybox    <none>    sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf   4986bf8c1536    9 weeks ago     2.43 MB
   106  ```
   107  
   108  To remove an image using its digest:
   109  
   110  ```bash
   111  $ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
   112  Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
   113  Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
   114  Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
   115  Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
   116  ```