©
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
删除一个或多个图像
docker rmi [OPTIONS] IMAGE [IMAGE...]
Name, shorthand | Default | Description |
---|---|---|
--force, -f | false | Force removal of the image |
--no-prune | false | Do not delete untagged parents |
Command | Description |
---|---|
docker | The base command for the Docker CLI. |
您可以使用其短或长 ID,其标记或摘要来移除图像。如果图像具有一个或多个引用它的标签,则必须在删除图像之前将其全部删除。摘要引用会在标签删除图像时自动删除。
$ 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 force2013/12/11 05:47:16 Error: failed to remove one or more images $ docker rmi test1 Untagged: test1:latest $ docker rmi test2 Untagged: test2:latest $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)$ docker rmi test Untagged: test:latest Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
如果您使用该-f
标志并指定图像的短或长 ID,那么此命令将除去并删除与指定 ID 匹配的所有图像。
$ 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 Untagged: test1:latest Untagged: test:latest Untagged: test2:latest Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
摘要所提取的图像没有与其关联的标记:
$ docker images --digests REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
若要使用图像摘要删除图像,请执行以下操作:
$ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125 Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2 Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b