如何分析Docker容器的磁盘使用情况 [英] How to analyze disk usage of a Docker container

查看:328
本文介绍了如何分析Docker容器的磁盘使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以看到Docker占用了12GB的文件系统:

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?

我尝试通过运行(新的v1.3命令)将其附加到容器上

I tried to attach to the containers by running (the new v1.3 command)

docker exec -it <container_name> bash

,然后运行"df -h"以分析磁盘使用情况.似乎可行,但不适用于使用"volumes-from"的容器.

and then running 'df -h' to analyze the disk usage. It seems to be working, but not with containers that use 'volumes-from'.

例如,我为MongoDB使用了仅数据容器,称为"mongo-data".

For example, I use a data-only container for MongoDB, called 'mongo-data'.

当我先运行docker run -it --volumes-from mongo-data busybox,然后在容器内运行df -h时,它表示安装在/data/db(我的"mongo-data"仅数据容器)上的文件系统使用11.3G,但是当我执行du -h /data/db,它说它仅使用2.1G.

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.

那么,如何分析容器/卷磁盘使用情况?或者,就我而言,如何找出"mongo-data"容器的大小?

So, how do I analyze a container/volume disk usage? Or, in my case, how do I find out the 'mongo-data' container size?

推荐答案

要查看容器的文件大小,可以使用docker ps--size参数:

To see the file size of your containers, you can use the --size argument of docker ps:

docker ps --size

这篇关于如何分析Docker容器的磁盘使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆