3

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?

1

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.