Reputation: 81
I just cloned a project from GitHub and in the readme file it asks me to run docker-compose up
to run the PostgreSQL image...
I assume that after I run the command, the PostgreSQL server image will start in the Docker container on my pc using port 5432. Then I run npm install
and npm start
to start the project (the database tables will be automatically created using an ORM framework). However, when I open my pgAdmin to connect to the server, it says it successfully connected but I could not find those tables created. Here I guess the pgAdmin didn't connect the PostgreSQL server (Docker image) on 5432... So my question is whether it is possible to use pgAmin installed in my local pc to connect to the PostgreSQL server Docker image which is already running, mapping to the port 5432 of my local PC?
Upvotes: 3
Views: 7442
Reputation: 2523
docker ps --format "table {{.Names}}\t{{.ID}}" | grep 'postgres'
The above command will give a list of containers name and Id of Postgres container running via docker. if you have multiple Postgres container, pick one that you want to add in Pg-Admin and use the container id of that Postgres container for next command
docker inspect <container id> | grep -E -A 1 "IPAddress|Ports"
It will give the IPAddress and port of Postgres container you want to connect via PG-Admin. Use that IPAddress and Port to connect via Pg-Admin
Upvotes: 5
Reputation: 4360
Yes, its possible you just have to get Ip address from Docker container, run the next commands to reach that.
docker ps
and then use the ID container to:
docker inspect ID container
Search by IPAddress from Docker config and use it to connect from pgAdmin.
Upvotes: 3