jorgeas80 February 2016

Proper way to monitor PostgreSQL running inside a docker container

I'm running a docker container with CentOS 7 + PostgreSQL 9.4. Using this docker image.

So, after pulling the image, I've created the container, following the instructions, and exposing the PostgreSQL port 5432.

Of course, I can execute a shell in my container, by doing this

docker exec -it CONTAINER_NAME /bin/bash

After that, I'm logged as postgres user. But I need to install more software (basically, postgres related stuff, or some command line tools).

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).

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. Or even use my host machine (Mac OS X) for that. But then... How could I use commands like lsof, or htop? I need to be in the same container that runs PostgreSQL for that.

Am I right?

Answers


jorgeas80 February 2016

Ok, that was easy

docker exec -it -u root CONTAINER_NAME /bin/bash -c "yum install lsof"

Post Status

Asked in February 2016
Viewed 1,069 times
Voted 5
Answered 1 times

Search




Leave an answer