...
1# rmi
2
3<!---MARKER_GEN_START-->
4Remove one or more images
5
6### Aliases
7
8`docker image rm`, `docker image remove`, `docker rmi`
9
10### Options
11
12| Name | Type | Default | Description |
13|:----------------|:-----|:--------|:-------------------------------|
14| `-f`, `--force` | | | Force removal of the image |
15| `--no-prune` | | | Do not delete untagged parents |
16
17
18<!---MARKER_GEN_END-->
19
20## Description
21
22Removes (and un-tags) one or more images from the host node. If an image has
23multiple tags, using this command with the tag as a parameter only removes the
24tag. If the tag is the only one for the image, both the image and the tag are
25removed.
26
27This does not remove images from a registry. You cannot remove an image of a
28running container unless you use the `-f` option. To see all images on a host
29use the [`docker image ls`](image_ls.md) command.
30
31## Examples
32
33You can remove an image using its short or long ID, its tag, or its digest. If
34an image has one or more tags referencing it, you must remove all of them before
35the image is removed. Digest references are removed automatically when an image
36is removed by tag.
37
38```console
39$ docker images
40
41REPOSITORY TAG IMAGE ID CREATED SIZE
42test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
43test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
44test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
45
46$ docker rmi fd484f19954f
47
48Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
492013/12/11 05:47:16 Error: failed to remove one or more images
50
51$ docker rmi test1:latest
52
53Untagged: test1:latest
54
55$ docker rmi test2:latest
56
57Untagged: test2:latest
58
59
60$ docker images
61
62REPOSITORY TAG IMAGE ID CREATED SIZE
63test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
64
65$ docker rmi test:latest
66
67Untagged: test:latest
68Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
69```
70
71If you use the `-f` flag and specify the image's short or long ID, then this
72command untags and removes all images that match the specified ID.
73
74```console
75$ docker images
76
77REPOSITORY TAG IMAGE ID CREATED SIZE
78test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
79test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
80test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
81
82$ docker rmi -f fd484f19954f
83
84Untagged: test1:latest
85Untagged: test:latest
86Untagged: test2:latest
87Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
88```
89
90An image pulled by digest has no tag associated with it:
91
92```console
93$ docker images --digests
94
95REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
96localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
97```
98
99To remove an image using its digest:
100
101```console
102$ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
103Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
104Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
105Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
106Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
107```
View as plain text