有没有办法查看Windows版Docker上容器磁盘的使用情况? [英] Is there a way to see container disk usage on Docker for Windows?
问题描述
我很好奇,是否有一种方法可以查看正在运行的Windows容器使用的磁盘空间,以及该容器映像中包含的层。基本上,容器自创建以来增长了多少。
I'm curious if there's a way to see how much disk space a running Windows container is using in addition to the layers that are part of the container's image. Basically, how much the container "grew" since it was created.
在Linux(或在HyperV中运行的Linux容器)中,这将是 docker ps -s
,但是该命令未在Windows容器上实现。我还尝试了 docker system df -v
,但是也没有实现。
In Linux (Or Linux containers running in a HyperV), this would be docker ps -s
, however that command isn't implemented on Windows containers. I also tried docker system df -v
but also, not implemented. Perhaps there's a hacky way by looking at a certain directly on disk or something?
推荐答案
我检查了运行于非Windows 10操作系统的Windows 10 1809, HyperV(进程隔离)容器,我非常确定Windows Server容器也是如此。
I checked on Windows 10 1809 running non-HyperV (process isolation) containers, I'm pretty sure its the same for Windows Server containers.
数据似乎保存在:
C:\ProgramData\Docker\windowsfilter\{ContainerId}
在 GraphDriver\Data\下的
。 docker inspect {Id}
中直接引用了该文件夹\dir
There's a direct reference to the folder in docker inspect {Id}
under GraphDriver\Data\dir
.
该文件夹包含文件 sandbox.vhdx
,似乎是每个容器的可写层。
The folder contains file sandbox.vhdx
which appears to be the "writable layer" of each container.
我无法打开它并查看文件系统,但是如果我在容器中写入一些数据,我可以强制该文件增长:
I wasn't able to open it and view the filesystem, but if I write some data inside the container I can force the file to grow:
docker exec <Id> powershell get-childitem c:\ -recurse `> c:\windows\temp\test.txt
当容器停止时该层仍然存在/ restarted,并且在容器 rm
ed时删除文件夹。
The layer persists when the container is stopped/restarted, and the folder is removed when the container is rm
ed.
在研究时,我看到了在moby中打开PR 可以改善对该文件夹的清理。
While researching I saw an open PR in moby to improve cleanup of this folder.
这篇关于有没有办法查看Windows版Docker上容器磁盘的使用情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!