2016-10-14 18:30:36 -04:00
|
|
|
---
|
|
|
|
title: "rmi"
|
|
|
|
description: "The rmi command description and usage"
|
2016-11-03 18:48:30 -04:00
|
|
|
keywords: "remove, image, Docker"
|
2016-10-14 18:30:36 -04:00
|
|
|
---
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2017-10-04 13:03:55 -04:00
|
|
|
<!-- This file is maintained within the docker/cli GitHub
|
2017-07-28 13:28:23 -04:00
|
|
|
repository at https://github.com/docker/cli/. Make all
|
2016-10-19 13:25:45 -04:00
|
|
|
pull requests against that repo. If you see this file in
|
|
|
|
another repository, consider it read-only there, as it will
|
|
|
|
periodically be overwritten by the definitive file. Pull
|
|
|
|
requests which include edits to this file in other repositories
|
|
|
|
will be rejected.
|
|
|
|
-->
|
|
|
|
|
2015-06-21 16:41:38 -04:00
|
|
|
# rmi
|
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
```markdown
|
|
|
|
Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
Remove one or more images
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2016-07-07 14:43:18 -04:00
|
|
|
Options:
|
|
|
|
-f, --force Force removal of the image
|
|
|
|
--help Print usage
|
|
|
|
--no-prune Do not delete untagged parents
|
|
|
|
```
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Examples
|
|
|
|
|
2015-06-21 16:41:38 -04:00
|
|
|
You can remove an image using its short or long ID, its tag, or its digest. If
|
2017-10-02 00:36:13 -04:00
|
|
|
an image has one or more tags referencing it, you must remove all of them before
|
2016-01-06 20:57:21 -05:00
|
|
|
the image is removed. Digest references are removed automatically when an image
|
|
|
|
is removed by tag.
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
```bash
|
|
|
|
$ docker images
|
|
|
|
|
|
|
|
REPOSITORY TAG IMAGE ID CREATED SIZE
|
|
|
|
test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
|
|
|
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
|
|
|
test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
|
|
|
|
|
|
|
$ docker rmi fd484f19954f
|
|
|
|
|
|
|
|
Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
|
|
|
|
2013/12/11 05:47:16 Error: failed to remove one or more images
|
|
|
|
|
2018-10-13 12:56:41 -04:00
|
|
|
$ docker rmi test1:latest
|
2017-02-07 18:42:48 -05:00
|
|
|
|
|
|
|
Untagged: test1:latest
|
|
|
|
|
2018-10-13 12:56:41 -04:00
|
|
|
$ docker rmi test2:latest
|
2017-02-07 18:42:48 -05:00
|
|
|
|
|
|
|
Untagged: test2:latest
|
|
|
|
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
$ docker images
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
REPOSITORY TAG IMAGE ID CREATED SIZE
|
|
|
|
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2018-10-13 12:56:41 -04:00
|
|
|
$ docker rmi test:latest
|
2017-02-07 18:42:48 -05:00
|
|
|
|
|
|
|
Untagged: test:latest
|
|
|
|
Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
|
|
|
|
```
|
2015-06-21 16:41:38 -04:00
|
|
|
|
|
|
|
If you use the `-f` flag and specify the image's short or long ID, then this
|
|
|
|
command untags and removes all images that match the specified ID.
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
```bash
|
|
|
|
$ docker images
|
|
|
|
|
|
|
|
REPOSITORY TAG IMAGE ID CREATED SIZE
|
|
|
|
test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
|
|
|
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
|
|
|
test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
|
|
|
|
|
|
|
$ docker rmi -f fd484f19954f
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
Untagged: test1:latest
|
|
|
|
Untagged: test:latest
|
|
|
|
Untagged: test2:latest
|
|
|
|
Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
|
|
|
|
```
|
2015-06-21 16:41:38 -04:00
|
|
|
|
|
|
|
An image pulled by digest has no tag associated with it:
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
```bash
|
|
|
|
$ docker images --digests
|
|
|
|
|
|
|
|
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
|
|
|
|
localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
|
|
|
|
```
|
2015-06-21 16:41:38 -04:00
|
|
|
|
|
|
|
To remove an image using its digest:
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
```bash
|
|
|
|
$ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
|
|
|
|
Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
|
|
|
|
Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
|
|
|
|
Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
|
|
|
|
Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
|
|
|
|
```
|