Hoy comparto la receta para poder levantar una base de datos PostgreSQL en Docker Compose.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
# Create a service named db. | |
db: | |
# Use the Docker Image postgres. This will pull the newest release. | |
image: "postgres" | |
# Give the container the name my_postgres. You can changes to something else. | |
container_name: "demo_uno_postgres" | |
# Setup the username, password, and database name. You can changes these values. | |
environment: | |
- POSTGRES_USER=u_demo | |
- POSTGRES_PASSWORD=pwd0123456789 | |
- POSTGRES_DB=db_demo_uno | |
# Maps port 54320 (localhost) to port 5432 on the container. You can change the ports to fix your needs. | |
ports: | |
- "5432:5432" | |
# Set a volume some that database is not lost after shutting down the container. | |
# I used the name postgres-data but you can changed it to something else. | |
volumes: | |
- ./postgres-data:/var/lib/postgresql/data |