Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker stat network traffic

I want ask 2 question about docker stats

for example

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

in this situation net i/o statement 2.99GB / 372MB how much time reflected in that?

for one hour? or all of time?

and how can check docker container network traffic for an hour or minute?

i would appreciate if you any other advice. thank you

like image 599
Koon7022 Avatar asked Oct 12 '17 08:10

Koon7022


1 Answers

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.

like image 179
sauerburger Avatar answered Oct 19 '22 14:10

sauerburger