How can i see PostgreSQL UI in pgAdmin if the db is in Docker?

Viewed 407

I have installed one open-source project from docker and that project has a database in PostgreSQL. Now I want to see the database from pgAdmin 4 and when I am trying to connect with "host.docker.internal" I am getting an error see image below.

enter image description here

2 Answers

Simply do mapping port for your PostgreSQL (which is running inside Docker). and from your pgAdmin4 you'll connect using localhost:<mapped_port>

If you're using docker-compose

services:
  postgre:
    ports:
      - "8080:5432"

If you're using docker-cli

docker run postgre -p 8080:5432

Then from pgAdmin4 connect to your database using localhost:8080

I suspect this is a networking issue.

If port mapping does not work as suggested in other answers, try specifying the network as host for your container

If you are using docker run

--net=host 

Or use the following on docker compose

network_mode: 'host'
Related