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: [email protected]
            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.

1
  • 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. Commented Jun 19, 2021 at 18:05

1 Answer 1

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

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

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.