Niloy Rony
Niloy Rony

Reputation: 632

How do I connect pgadmin with postgres after installed by docker?

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.

Upvotes: 0

Views: 185

Answers (1)

JRichardsz
JRichardsz

Reputation: 16515

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

Upvotes: 1

Related Questions