Docker统计网络流量

时间:2017-10-12 08:20:40

标签: docker networking network-traffic

我想问2关于码头统计数据的问题

例如

NAME                              CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
container_1                       1.52%               11.72MiB / 7.388GiB   0.15%               2.99GB / 372MB      9.4MB / 0B          9

在这种情况下net i / o语句2.99GB / 372MB 多少时间反映在那?

一小时?还是所有的时间?

如何查看docker容器网络流量一小时或一分钟?

如果您有任何其他建议,我将不胜感激。 谢谢

1 个答案:

答案 0 :(得分:2)

This blog explains the network io of the docker stats command

Displays total bytes received (RX) and transmitted (TX).

If you need finer grained access, the blog also suggests to use the network pseudo files on your host system.

$ CONTAINER_PID=`docker inspect -f '{{ .State.Pid }}' $CONTAINER_ID`
$ cat /proc/$CONTAINER_PID/net/dev

To your second part: I'm not aware of any build-in method to get the traffic over the specific period, others might correct me. I think the easiest solution is to poll one of the two interfaces and calculate the differences yourself.