pgweb
Web-based PostgreSQL database browser.
Overview
pgweb is a lightweight, cross-platform web-based PostgreSQL database browser written in Go that transforms database management into an intuitive web interface. Created by Dan Sosedoff in 2014, pgweb eliminates the need for heavy desktop clients like pgAdmin by providing instant browser-based access to PostgreSQL databases with zero client-side installation requirements. The tool has gained popularity among developers for its simplicity, speed, and ability to work across all operating systems through any modern web browser.
This Docker stack combines pgweb with a PostgreSQL 16 Alpine container to create a complete database development environment where both the database server and web interface run in isolated containers. The setup uses Docker networking to enable pgweb to connect directly to the PostgreSQL instance using the DATABASE_URL environment variable, eliminating manual connection configuration. The Alpine-based PostgreSQL image keeps the overall footprint minimal while providing the latest PostgreSQL features and security updates.
Developers working on PostgreSQL-based applications, database administrators managing multiple environments, and teams needing collaborative database access will find this stack invaluable. The combination provides instant database provisioning with immediate web-based access, making it perfect for development environments, database prototyping, and situations where installing desktop database clients is impractical or restricted.
Key Features
- Interactive SQL query editor with syntax highlighting and auto-completion for PostgreSQL
- Real-time table browsing with pagination, sorting, and filtering capabilities
- Schema visualization showing tables, indexes, constraints, and relationships
- Built-in data export functionality supporting CSV, JSON, and XML formats
- Query execution history stored locally in browser for session persistence
- Read-only mode accessible via URL parameter for safe production database browsing
- Responsive web interface that works across desktop and mobile devices
- PostgreSQL 16 Alpine integration with automatic connection configuration via environment variables
Common Use Cases
- 1Local development environment for PostgreSQL-based web applications and APIs
- 2Quick database prototyping and schema design without installing desktop tools
- 3Remote database administration when SSH tunneling to command-line tools is impractical
- 4Team collaboration on database queries and data analysis in shared development environments
- 5Educational environments where students need browser-based database access
- 6Docker-based CI/CD pipelines requiring database inspection and validation steps
- 7Homelab setups for personal projects requiring lightweight database management tools
Prerequisites
- Docker Engine 20.10+ and Docker Compose V2 for container orchestration
- Minimum 512MB available RAM for PostgreSQL and pgweb containers combined
- Port 8081 available on host system for pgweb web interface access
- Basic understanding of PostgreSQL concepts like databases, tables, and SQL queries
- Environment file (.env) with DB_NAME, DB_USER, and DB_PASSWORD variables defined
- Web browser with JavaScript enabled for optimal pgweb interface functionality
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 pgweb: 3 image: sosedoff/pgweb:latest4 container_name: pgweb5 restart: unless-stopped6 ports: 7 - "8081:8081"8 environment: 9 DATABASE_URL: postgres://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}10 networks: 11 - pgweb1213 postgres: 14 image: postgres:16-alpine15 container_name: postgres16 environment: 17 POSTGRES_DB: ${DB_NAME}18 POSTGRES_USER: ${DB_USER}19 POSTGRES_PASSWORD: ${DB_PASSWORD}20 volumes: 21 - postgres_data:/var/lib/postgresql/data22 networks: 23 - pgweb2425volumes: 26 postgres_data: 2728networks: 29 pgweb: 30 driver: bridge.env Template
.env
1DB_NAME=mydb2DB_USER=postgres3DB_PASSWORD=changemeUsage Notes
- 1Docs: https://sosedoff.github.io/pgweb/
- 2Access at http://localhost:8081 - auto-connects via DATABASE_URL
- 3Run SQL queries with syntax highlighting
- 4Browse tables, view schema, export CSV/JSON
- 5Query history saved in browser
- 6Read-only mode: add ?readonly to URL for safety
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
pgweb
pgweb:
image: sosedoff/pgweb:latest
container_name: pgweb
restart: unless-stopped
ports:
- "8081:8081"
environment:
DATABASE_URL: postgres://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}
networks:
- pgweb
postgres
postgres:
image: postgres:16-alpine
container_name: postgres
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- pgweb
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 pgweb:5 image: sosedoff/pgweb:latest6 container_name: pgweb7 restart: unless-stopped8 ports:9 - "8081:8081"10 environment:11 DATABASE_URL: postgres://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}12 networks:13 - pgweb1415 postgres:16 image: postgres:16-alpine17 container_name: postgres18 environment:19 POSTGRES_DB: ${DB_NAME}20 POSTGRES_USER: ${DB_USER}21 POSTGRES_PASSWORD: ${DB_PASSWORD}22 volumes:23 - postgres_data:/var/lib/postgresql/data24 networks:25 - pgweb2627volumes:28 postgres_data:2930networks:31 pgweb:32 driver: bridge33EOF3435# 2. Create the .env file36cat > .env << 'EOF'37DB_NAME=mydb38DB_USER=postgres39DB_PASSWORD=changeme40EOF4142# 3. Start the services43docker compose up -d4445# 4. View logs46docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/pgweb/run | bashTroubleshooting
- Connection refused error in pgweb: Ensure PostgreSQL container is fully started before pgweb attempts connection by adding depends_on or health checks
- pgweb shows 'pq: password authentication failed': Verify DB_USER and DB_PASSWORD environment variables match between both containers
- Cannot access pgweb at localhost:8081: Check if port 8081 is already in use by another service using 'netstat -tulpn | grep 8081'
- PostgreSQL data not persisting after container restart: Confirm postgres_data volume is properly mounted to /var/lib/postgresql/data
- pgweb interface loads but shows no tables: Ensure the database specified in DB_NAME actually exists and contains tables to browse
- Query execution timeout in pgweb: Large queries may need increased timeout settings via PGWEB_QUERY_TIMEOUT environment variable
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download