0

This is my docker-compose.yml

services:

    db:
        container_name: postgres
        image: postgres:latest
        restart: always
        environment:
            POSTGRES_USER: root
            POSTGRES_PASSWORD: root
            POSTGRES_DB: test_db
    pgadmin:
        container_name: pgadmin
        image: dpage/pgadmin4
        restart: always
        environment: 
            PGADMIN_DEFAULT_EMAIL: admin@test.com
            PGADMIN_DEFAULT_PASSWORD: admin123
        ports:
            - 8002:80

Pg-admin is running in port 8002

To connect pgsql with pgadmin I have used below credential to add new server in pgadmin, I am getting below error,

enter image description here

How do I will map this connection ?

In docker panel it's showing postgres is running

enter image description here My operating system : Mac m1.

Niloy Rony
  • 602
  • 1
  • 8
  • 23
  • Few things to check, is postgres running, if it is running is the Port open if you are not listening in the loopback device, if you are not listening in loopback you might need to edit your pg_hba.conf. if your postgres is using a stocket you need to Connect to the socket not the nic with 127.0 0.1 or your external up. – Markus Rosjat Jun 19 '21 at 18:05

1 Answers1

1

When you using more than one container and there are related, localhost not works.

Instead of localhost set the ip of the host in which your postgress is running.

Read these topics to understand ip vs localhost in docker

JRichardsz
  • 14,356
  • 6
  • 59
  • 94