i have created 2 containers [pgadmin4 , postgres ] using below docker compose file.
services:
db:
container_name: db
image: postgres
environment:
POSTGRES_USER: ashish
POSTGRES_PASSWORD: ashish
PGDATA: /data/postgres
POSTGRESS_DB: jobapp
ports:
- "5432:5432"
networks:
- postgres
restart: always
pgadmin:
container_name: pgadmin4
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"
networks:
- postgres
restart: always
networks:
postgres:
name: postgres
driver: bridge
- for both containers, i am using same bridge network namely postgres.
- i checked ping status as below to ensure the communication ok.
I logged in pgadmin4 over localhost:5050. then i tried creating a server using the credentials passed in compose file.here the address is passed as network name which is 'postgres'
with above values, getting error as Name not reloved. then i tried address as 'localhost' and '0.0.0.0' as well but still it failed with error message as connection refused.
NETWORK ID NAME DRIVER SCOPE
1d1c44a0b064 bridge bridge local
0e0a1145cf91 host host local
06fa74116375 my-network bridge local
7e93df1725d9 none null local
2a74ae7944da postgres bridge local
above is the response of docker network ls.
cat /data/postgres/pg_hba.conf from db container is resulting into below table.
thanks in advance for your valuable time. any attention is highly appreciated.



db, because that's what you chose to call it in your compose file.db. If the application is running anywhere else, that won't work. If it's running directly on your host, you should be able to uselocalhostbecause you are publishing the postgres ports to your host. If that's not working, you may want to open a new question for that specific issue.