?? Docker, PostgreSQL, and pgAdmin working together ????????
It's a common doubt for developers when they want to work with Docker, PostgreSQL, and pgAdmin: How do I started it? I remember seen a docker-compose.yaml somewhere...
So use this article as reference and keep it in your bookmarks to use it whenever you need ??
Here's a basic docker-compose.yml setup for a PostgreSQL database with pgAdmin. This setup will spin up two services: one for PostgreSQL and another for pgAdmin, allowing you to manage the database through a web interface.
services:
postgres:
image: postgres:latest
container_name: postgres_db
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: [email protected] # Set your admin email
PGADMIN_DEFAULT_PASSWORD: admin # Set your pgAdmin password
ports:
- "8080:80"
depends_on:
- postgres
volumes:
- pgadmin_data:/var/lib/pgadmin
volumes:
postgres_data:
pgadmin_data:
Explanation
Uses the postgres:latest image.
Defines environment variables for the database user, password, and default database.
Maps port 5432 on the host to 5432 in the container.
Uses the dpage/pgadmin4 image.
Sets environment variables for the pgAdmin default email and password.
Maps port 8080 on the host to 80 in the container (pgAdmin's default port).
领英推荐
postgres_data: Used to persist PostgreSQL data on the host.
pgadmin_data: Used to persist pgAdmin data on the host.
Usage
Host: postgres_db
Port: 5432
Username: your_username
Password: your_password
Feel free to reach me out for questions! See you in the comments ??
Java Backend Developer | Spring Certified Professional | Spring Boot | AWS | ReactJS | Fullstack Software Engineer
4 个月Very informative
Senior Business Analyst | ITIL | Communication | Problem-Solving | Critical Thinking | Data Analysis and Visualization | Documentation | BPM | Time Management | Agile | Jira | Requirements Gathering | Scrum
4 个月Interesting! Thanks for sharing Rodrigo Tenório ! ????
Senior Fullstack Engineer | Front-End focused developer | React | Next.js | Vue | Typescript | Node | Laravel | .NET | Azure | AWS
4 个月Thanks for this clear explanation of Docker Compose setup for PostgreSQL and pgAdmin! Great step-by-step guide for easy database management. Appreciate the helpful usage instructions.
Data Scientist Specialist | Machine Learning | LLM | GenAI | NLP | AI Engineer
4 个月Setting up PostgreSQL with pgAdmin in Docker has never been easier—this guide is a lifesaver for quick and efficient database management!