Skip to content

Instantly share code, notes, and snippets.

@troke12
Created June 2, 2025 02:31
Show Gist options
  • Save troke12/a5daac2b4955de71096e34b84476b9b8 to your computer and use it in GitHub Desktop.
Save troke12/a5daac2b4955de71096e34b84476b9b8 to your computer and use it in GitHub Desktop.
PostgreSQL, MySQL, Redis
version: '3.8' # Specifies the version of the Docker Compose file format
services:
postgres:
image: postgres:latest # Uses the latest official PostgreSQL image
container_name: my_postgres_container
environment:
POSTGRES_USER: user # Replace with your desired username
POSTGRES_PASSWORD: password # Replace with your desired password
POSTGRES_DB: mydatabase # Replace with your desired database name
ports:
- "5432:5432" # Maps port 5432 on the host to port 5432 in the container
volumes:
- postgres_data:/var/lib/postgresql/data # Persists PostgreSQL data
restart: unless-stopped # Restarts the container unless it's manually stopped
mysql:
image: mysql:latest # Uses the latest official MySQL image
container_name: my_mysql_container
environment:
MYSQL_ROOT_PASSWORD: rootpassword # Replace with your desired root password
MYSQL_DATABASE: mydatabase # Replace with your desired database name
MYSQL_USER: user # Replace with your desired username
MYSQL_PASSWORD: password # Replace with your desired password
ports:
- "3306:3306" # Maps port 3306 on the host to port 3306 in the container
volumes:
- mysql_data:/var/lib/mysql # Persists MySQL data
restart: unless-stopped # Restarts the container unless it's manually stopped
redis:
image: redis:latest # Uses the latest official Redis image
container_name: my_redis_container
ports:
- "6379:6379" # Maps port 6379 on the host to port 6379 in the container
volumes:
- redis_data:/data # Persists Redis data
restart: unless-stopped # Restarts the container unless it's manually stopped
volumes: # Defines named volumes for data persistence
postgres_data:
mysql_data:
redis_data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment