Skip to content

musay/postgres-pgadmin-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL + pgAdmin — Local Dev Setup

A minimal Docker Compose setup for running PostgreSQL 16 and pgAdmin 4 locally.

Requirements

Getting Started

1. Clone the repo

git clone https://github.com/musay/postgres-pgadmin-docker
cd postgres-pgadmin-docker

2. Configure environment

cp .env.example .env

Edit .env with your preferred credentials:

POSTGRES_USER=devuser
POSTGRES_PASSWORD=devpass
POSTGRES_DB=devdb

PGADMIN_EMAIL=admin@local.dev
PGADMIN_PASSWORD=adminpass

3. Start services

docker-compose up -d

4. Stop services

docker-compose down        # stop (data persists)
docker-compose down -v     # stop + wipe all data

Services

Service URL / Port Default Credentials
PostgreSQL localhost:5432 see .env
pgAdmin http://localhost:5050 see .env

Connecting pgAdmin to PostgreSQL

After opening http://localhost:5050, add a new server with:

Field Value
Host postgres
Port 5432
Database devdb
Username devuser
Password devpass

⚠️ Use postgres as the host — not localhost. Services communicate over the internal Docker network.


Connecting from your app

JDBC (Spring Boot)

spring.datasource.url=jdbc:postgresql://localhost:5432/devdb
spring.datasource.username=devuser
spring.datasource.password=devpass

psql CLI

docker exec -it postgres_dev psql -U devuser -d devdb

Data Persistence

Data is stored in a named Docker volume (pgdata). It survives docker-compose down restarts.

To fully reset:

docker-compose down -v

Project Structure

.
├── docker-compose.yml
├── .env                  # local credentials (not committed)
├── .env.example          # template — safe to commit
├── .gitignore
└── README.md

.gitignore

Make sure your .gitignore includes:

.env
postgres-data/

Never commit .env — it contains credentials.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors