Reputation: 91666
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.
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?
Upvotes: 2
Views: 6999
Reputation: 12310
I checked on Windows 10 1809 running non-HyperV (process isolation) containers, I'm pretty sure its the same for Windows Server containers.
The data seems to be kept in:
C:\ProgramData\Docker\windowsfilter\{ContainerId}
There's a direct reference to the folder in docker inspect {Id}
under GraphDriver\Data\dir
.
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
The layer persists when the container is stopped/restarted, and the folder is removed when the container is rm
ed.
While researching I saw an open PR in moby to improve cleanup of this folder.
Upvotes: 2
Reputation: 333
I'm using docker for windows (docker desktop 2.0.0.3) and docker ps -s
is actually implemented.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
81acb264aa0f httpd "httpd-foreground" 6 minutes ago Up 6 minutes 80/tcp httpd 2B (virtual 132MB)
Docker for windows runs on a MobyLinuxVM. You can access the VM and the docker directories:
docker run --privileged -it -v /var/run/docker.sock:/var/run/docker.sock jongallant/ubuntu-docker-client
root@8b58d2fbe186:/# docker run --net=host --ipc=host --uts=host --pid=host –it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
root@8b58d2fbe186:/# chroot /host
Now you can access the docker folders in /var/lib/docker
as on linux and check the sizes.
Upvotes: 1