按docker stats中的内存使用量排序 [英] Sort by memory usage in docker stats

查看:1065
本文介绍了按docker stats中的内存使用量排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以显示按容器的内存使用情况排序的docker stats?

Is there a way to display the docker stats sorted by memory usage of the containers?

我正在使用以下命令来显示带有其名称和名称的容器想要按内存使用情况对结果进行排序。

I am using the following command to display the container with their names and I want to sort the result by memory usage.

docker stats --format "table {{.Name}}\t{{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"

未排序的结果如下。

NAME                                                                   CONTAINER           CPU %               MEM USAGE / LIMIT
kafka3.interactive.8a38c338742464ffb04d6f23fc6485391318d103            0d68b7fd49a0        1.39%               359.5 MiB / 4.833 GiB
kafka2.interactive.8a38c338742464ffb04d6f23fc6485391318d103            7e5541b0b883        1.22%               309.4 MiB / 4.833 GiB
kafka1.interactive.8a38c338742464ffb04d6f23fc6485391318d103            dff07c6d639c        0.68%               267.4 MiB / 4.833 GiB
service2.interactive.8a38c338742464ffb04d6f23fc6485391318d103          0f20a7e75823        0.06%               617.8 MiB / 4.833 GiB
consulakms.interactive.8a38c338742464ffb04d6f23fc6485391318d103        b5972262194d        3.82%               10.32 MiB / 4.833 GiB
service1.interactive.8a38c338742464ffb04d6f23fc6485391318d103          be56185a37bf        0.09%               596.3 MiB / 4.833 GiB
consumer1.interactive.8a38c338742464ffb04d6f23fc6485391318d103         05145beb209c        0.06%               574.6 MiB / 4.833 GiB
consul1.interactive.8a38c338742464ffb04d6f23fc6485391318d103           3298a8159064        0.67%               10.57 MiB / 4.833 GiB
consul3.interactive.8a38c338742464ffb04d6f23fc6485391318d103           4a1bbbd131ad        3.12%               9.664 MiB / 4.833 GiB
zookeeper2.interactive.8a38c338742464ffb04d6f23fc6485391318d103        040f00b4bbc7        0.09%               42.45 MiB / 4.833 GiB
consulbootstrap.interactive.8a38c338742464ffb04d6f23fc6485391318d103   45268a11f2f4        3.62%               11.46 MiB / 4.833 GiB
zookeeper3.interactive.8a38c338742464ffb04d6f23fc6485391318d103        331772b27079        0.12%               51.27 MiB / 4.833 GiB
consul2.interactive.8a38c338742464ffb04d6f23fc6485391318d103           77b63171e6b5        1.07%               12.59 MiB / 4.833 GiB
zookeeper1.interactive.8a38c338742464ffb04d6f23fc6485391318d103        c5ad82730598        0.08%               43.17 MiB / 4.833 GiB
service3.interactive.8a38c338742464ffb04d6f23fc6485391318d103          610da86c6949        3.79%               546.7 MiB / 4.833 GiB
squid.interactive.8a38c338742464ffb04d6f23fc6485391318d103             928ddbb197fa        0.01%               144.2 MiB / 4.833 GiB


推荐答案

女士用量字段,您可以使用以下命令:

To sort by Mem Usage field you can use the following command:

GNU / Linux:

GNU/Linux:

docker stats --no-stream --forma t表{{.Name}} \t {{。Container}} \t {{。CPUPerc}} \t {{。MemUsage}} |排序-k 4 -h

MacOS:

docker stats --no-stream --format table {{.Name}} \t {{。Container}} \t {{。CPUPerc}} \t {{。MemUsage}} \t { {.M‌emPerc}} | | sort -k 9 -n

选中此链接以查看所有可用选项,以-format docker stats 的$ c>选项: https://docs.docker.com/engine/reference/commandline/stats/#formatting

Check this link to view all available options to --format option of docker stats: https://docs.docker.com/engine/reference/commandline/stats/#formatting

这篇关于按docker stats中的内存使用量排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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