Docker服务器负载较高,通过top可以看到是rabbitmq占用CPU资源,本机是没有安装这个软件的,那么只能是某个容器中在运行。
问题是现在并不知道哪个容器。
通过ps aux | grep rabbitmq
查询到执行文件为rabbitmq-server,搜索Docker容器卷中是否有对应的问题。
find /var/lib/docker/overlay2 -type f -name rabbitmq-server
# stdout
/var/lib/docker/overlay2/b21bb64c4ed9c800bdb802af431ae963141797d5f40864386b99bc46e10f9009/merged/etc/default/rabbitmq-server
/var/lib/docker/overlay2/b21bb64c4ed9c800bdb802af431ae963141797d5f40864386b99bc46e10f9009/merged/etc/init.d/rabbitmq-server
/var/lib/docker/overlay2/b21bb64c4ed9c800bdb802af431ae963141797d5f40864386b99bc46e10f9009/merged/etc/logrotate.d/rabbitmq-server
/var/lib/docker/overlay2/b21bb64c4ed9c800bdb802af431ae963141797d5f40864386b99bc46e10f9009/merged/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server
/var/lib/docker/overlay2/b21bb64c4ed9c800bdb802af431ae963141797d5f40864386b99bc46e10f9009/merged/usr/lib/rabbitmq/lib/rabbitmq_server-3.8.2/sbin/rabbitmq-server
/var/lib/docker/overlay2/15d08356a74da702ec8c357146e3378d8ddce69ac55805c21f20dfdf8435548d/diff/etc/default/rabbitmq-server
/var/lib/docker/overlay2/15d08356a74da702ec8c357146e3378d8ddce69ac55805c21f20dfdf8435548d/diff/etc/init.d/rabbitmq-server
/var/lib/docker/overlay2/15d08356a74da702ec8c357146e3378d8ddce69ac55805c21f20dfdf8435548d/diff/etc/logrotate.d/rabbitmq-server
/var/lib/docker/overlay2/15d08356a74da702ec8c357146e3378d8ddce69ac55805c21f20dfdf8435548d/diff/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server
/var/lib/docker/overlay2/15d08356a74da702ec8c357146e3378d8ddce69ac55805c21f20dfdf8435548d/diff/usr/lib/rabbitmq/lib/rabbitmq_server-3.8.2/sbin/rabbitmq-server
这样我们就的能到是容器所使用的overlay目录,通过目录名称,定位到容器。
docker ps -q |xargs docker inspect --format '{{.State.Pid}} {{.Id}} {{.Name}} {{.GraphDriver.Data.WorkDir}}' | grep b21bb64c4ed9c800bdb802af431ae963141797d5f4086
# stdout
6189 2d4a09d2142b820672027036c3b7f9f1cf832c778613a3a0d5d7f4e33721856f /onlyoffice /var/lib/docker/overlay2/b21bb64c4ed9c800bdb802af431ae963141797d5f40864386b99bc46e10f9009/work