Docker - 如何分析容器的磁盘使用情况? [英] Docker - How to analyze a container's disk usage?
问题描述
我一直在搜索一段时间,但找不到分析Docker容器/卷的磁盘使用情况的方法。
我可以看到Docker需要12GB的文件系统:
2.7G / var / lib / docker / vfs / dir
2.7G / var / lib / docker / vfs
2.8G / var / lib / docker / devicemapper / mnt
6.3G / var / lib / docker / devicemapper / devicemapper
9.1G / var / lib / docker / devicemapper
12G / var / lib / docker
但是,我怎么知道这是分发在容器上?
我试图通过运行附加到容器(新的v1.3命令)
docker exec -it< container_name> bash
,然后运行'df -h'来分析磁盘使用情况。它似乎是工作,但不是使用'volume-from'的容器。
例如,我使用一个仅数据的容器MongoDB,称为数据'。
当我运行'docker运行-it --volumes - 从mongo-data busybox',然后在容器内'df -h'时,它说安装在'/ data / db'上的文件系统(我的'mongo-data'data-only容器)使用11.3G,但是当我做'du -h / data / db'时,它表示它只使用2.1G。
那么,如何分析容器/卷磁盘使用情况?或者,在我的情况下,如何找到'mongo-data'容器大小?
非常感谢,
要查看容器的文件大小,可以使用 -s 参数
docker ps
:
docker ps -s
pre>
I've been searching for a while, but couldn't find a way to analyze the disk usage of a Docker container / volume.
I can see that Docker takes 12GB of my filesystem:
2.7G /var/lib/docker/vfs/dir 2.7G /var/lib/docker/vfs 2.8G /var/lib/docker/devicemapper/mnt 6.3G /var/lib/docker/devicemapper/devicemapper 9.1G /var/lib/docker/devicemapper 12G /var/lib/docker
But, how do I know how this is distributed over the containers?
I tried to attach to the containers by running (the new v1.3 command)
docker exec -it <container_name> bash
and then running 'df -h' to analyze the disk usage. It seems to be working, but not with containers that use 'volumes-from'.
For example, I use a data-only container for MongoDB, called 'mongo-data'.
When I run 'docker run -it --volumes-from mongo-data busybox', and then 'df -h' inside the container, It says that the filesystem mounted on '/data/db' (my 'mongo-data' data-only container) uses 11.3G, but when I do 'du -h /data/db', it says that it uses only 2.1G.
So, how do I analyze a container/volume disk usage? Or, in my case, how do I find out the 'mongo-data' container size?
Many thanks,
解决方案To see the file size of your containers, you can use the
-s
argument ofdocker ps
:docker ps -s
这篇关于Docker - 如何分析容器的磁盘使用情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!