在 docker 系统 df 中显示的“可回收”空间是什么?

可以使用命令 docker system df(镜子)(在 Docker 1.13.0中引入)查看 Docker 磁盘的使用情况,例如:

username@server:~$ docker system df
TYPE                TOTAL               ACTIVE             SIZE                RECLAIMABLE
Images              44                  28                 114.7GB             84.84GB (73%)
Containers          86                  7                  62.43GB             41.67GB (66%)
Local Volumes       2                   1                  0B                  0B
Build Cache                                                0B                  0B

如何计算 docker system df中显示的“可回收”? 也就是说,它代表什么?

Docker 关于 docker system df的文件(镜子)没有解释,码头术语(镜子)没有包含术语“可回收”。

29502 次浏览

Hi @Franck Dernoncourt!
RECLAIMABLE is the space consumed by "unused" images (in the meaning of no containers based on thoses images is running). In other words and as @jordanm said, this is the total size of images you can remove without breaking anything, that is exactly why Docker will remove them if you run docker system prune -a or docker image prune -a. The -a tells Docker to remove all unused images, without it Docker only removes dangling (untagged) images.

You can learn more on how optimize your disk space with Docker here and here and of course Docker documentation for docker image prune and docker system prune.

It's worth mentioning in addition to Kerat's answer, the command you may be looking for to free up space listed as RECLAIMABLE is docker system prune -a --volumes. Volumes will not be pruned by default if you don't include the --volumes flag.