Step-by-step: Add Connection in pgAdmin#
Open pgAdmin You already have it open at
http://localhost:5050(based on your Docker setup).Click “Add New Server” You’ll find it in the “Quick Links” section or by right-clicking on Servers → Register → Server.
In the dialog:
General Tab
Name:
Local Docker Postgres(or any name you like)
Connection Tab
Host name / address: If pgAdmin and Postgres are in the same Docker Compose network (as in your
docker-compose.yml), use the service name:postgres
Don’t use
localhost— pgAdmin inside Docker can’t see your host machine’s localhost; it communicates through the Docker network. You can use service_name (in docker), for examplepostgresPort:
5432Maintenance database:
example_pgdbUsername:
rootPassword:
postgres
(These match your
docker-composeenvironment variables.)Here is sample docker-compose.yml
version: "3.9" services: postgres: image: "postgres" ports: - "5432:5432" environment: POSTGRES_PASSWORD: postgres POSTGRES_USER: root POSTGRES_DB: example_pgdb
Save Click Save — pgAdmin should now connect to your Postgres container.