简体   繁体   English

监视在Docker容器中运行的PostgreSQL的正确方法

[英]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.

相关问题 在docker容器中运行的Solr未连接到PostgreSQL数据库 - Solr running inside docker container is not connecting to PostgreSQL database 在Docker中运行PostgreSql - Running PostgreSql inside Docker 访问Vagrant的Docker容器中运行的PostgreSQL - Access PostgreSQL running in Docker container in Vagrant 如何连接到在 GCP 虚拟机上的 Docker 容器内运行的 PostgreSQL 服务器? - How can I connect to a PostgreSQL server running inside a Docker container on a GCP virtual machine? Postgresql 在 docker 容器内运行(gcp 远程实例)无法从本地 dbeaver 访问 - Postgresql running inside docker container (gcp remote instance) can't be accessed from dbeaver locally 在Docker容器中使用Flyway和嵌入式Postgresql运行测试时出现java.net.ConnectException - java.net.ConnectException when running test with Flyway and embedded Postgresql inside Docker container 无法连接到 docker 容器内的 postgresql - Can not connect to postgresql which is inside of a docker container 在 docker 容器中创建正在运行的 Postgres 服务 - Creating a running Postgres service inside a docker container 如何从本地 R 连接到在 Docker 容器中运行的 PostgreSQL? - How to connect to PostgreSQL running in Docker container from local R? Spring Boot、PostgreSQL 和 Docker - 在容器中运行时连接被拒绝 - Spring Boot, PostgreSQL, and Docker - Connection Refused whil Running in Container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM