[英]Proper way to monitor PostgreSQL running inside a docker container
I'm running a docker container with CentOS 7 + PostgreSQL 9.4 . 我正在使用CentOS 7 + PostgreSQL 9.4运行docker容器。 Using this docker image .
使用此docker映像 。
So, after pulling the image, I've created the container, following the instructions, and exposing the PostgreSQL port 5432. 因此,提取图像后,我按照说明创建了容器,并公开了PostgreSQL端口5432。
Of course, I can execute a shell in my container, by doing this 当然,我可以在容器中执行一个shell
docker exec -it CONTAINER_NAME /bin/bash
After that, I'm logged as postgres user . 之后,我以postgres用户身份登录。 But I need to install more software (basically, postgres related stuff, or some command line tools).
但是我需要安装更多软件 (基本上是与Postgres相关的东西,或某些命令行工具)。
EDIT: What I'd need, for example, is to install the lsof tool (not available by default in CentOS 7, can be installed with yum install lsof). 编辑:例如,我需要安装lsof工具(在CentOS 7中默认情况下不可用,可以与yum install lsof一起安装)。
So, I'd need a different user, able to install software . 因此, 我需要一个能够安装软件的其他用户 。 Unless...
除非...
I'm not doing things the right way, and what I really need is another container to monitorize PostgreSQL . 我没有以正确的方式做事,而我真正需要的是另一个监视PostgreSQL的容器 。 Or even use my host machine (Mac OS X) for that.
甚至可以使用我的主机 (Mac OS X)。 But then... How could I use commands like lsof, or htop ?
但是,那... 我该如何使用lsof或htop之类的命令 ? I need to be in the same container that runs PostgreSQL for that.
为此,我需要位于运行PostgreSQL的同一个容器中。
Am I right? 我对吗?
好吧,那很容易
docker exec -it -u root CONTAINER_NAME /bin/bash -c "yum install lsof"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.