为什么该docker image prune -a
命令没有回收任何空间?
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
没有正在运行的容器。
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
awsdevenv latest 41d1e7913346 2 minutes ago 1.57GB
<none> <none> da7eb8c6161b 52 minutes ago 1.57GB
我的理解(可能不正确)是docker image ls
显示这些图像已使用 1.57GB x 2 空间。
$ docker image prune -a
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:da7eb8c6161b53f9c93e2cf88a53d48dd44e412302c940b34f0efc680da22ebc
untagged: awsdevenv:latest
deleted: sha256:41d1e7913346f59695b573ef04b87f6d05d35333bd07839a5a5b0295e57fa274
Total reclaimed space: 0B
但总回收空间显示为0。这是为什么呢?
答案1
docker container ls
仅显示正在运行的容器。用于docker container ls -a
显示正在运行和已停止的容器。(文档)
现在您应该看到仍然存在的容器。