Search code examples
linuxpostgresqldockerredhat

how to troubleshoot PostgreSQL Docker setup on Linux


I was able to run 2 docker containers. I can see that they are running, but I don't see the actual services.

I followed steps here to set up a new postgresql instance and i can see it up and running:

[vagrant@localhost dev]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS                                     NAMES
fe1fd9c362a2        dpage/pgadmin4      "/entrypoint.sh"         15 hours ago        Up 15 hours               80/tcp, 443/tcp, 0.0.0.0:5050->5050/tcp   awesome_yonath
e2dc95062de8        dpage/pgadmin4      "/entrypoint.sh"         15 hours ago        Exited (0) 15 hours ago                                             zealous_boyd
f516085ac3e1        dpage/pgadmin4      "/entrypoint.sh"         15 hours ago        Exited (0) 15 hours ago                                             vibrant_noether
a01d9ec38f17        postgres            "docker-entrypoint.s…"   16 hours ago        Up 16 hours               0.0.0.0:5432->5432/tcp                    pg-docker

however when i try to use any of the postgres commands, and run top i don't see the service.

[vagrant@localhost dev]$ psql
bash: psql: command not found...
[vagrant@localhost dev]$ postgres
bash: postgres: command not found...

trying to figure out if I need to start the service manually, or how to troubleshoot this

my setup script:

mkdir -p $HOME/docker/volumes/postgres
docker pull postgres:9.6.11
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data  postgres

Solution

  • If I understand correctly you run the PostgreSql docker container in a Vagrant machine as a host. You cannot see the processes running in the container from the host. You could run an interactive shell inside the container to see the PostgreSql server processes, run top and more. Something like this:

    docker exec -it  <pg-container-id> bash
    

    or

    docker exec <pg-container-id> ps
    

    to list the processes.

    Hope it helps.