This Docker Compose configuration allows you to set up Metabase along with a PostgreSQL database.
This configuration is designed for Metabase version 3.9.
- Image: metabase/metabase:latest
- Container Name: metabase
- Hostname: metabase
- Volumes:
/dev/urandom:/dev/random:ro
- Ports:
3000:3000
- Environment Variables:
MB_DB_TYPE
: postgresMB_DB_DBNAME
: metabaseMB_DB_PORT
: 5432MB_DB_USER_FILE
: /run/secrets/db_userMB_DB_PASS_FILE
: /run/secrets/db_passwordMB_DB_HOST
: postgres
- Network: metanet1
- Secrets:
- db_password
- db_user
- Healthcheck:
- Test:
curl --fail -I http://localhost:3000/api/health || exit 1
- Interval: 15s
- Timeout: 5s
- Retries: 5
- Test:
- Image: postgres:latest
- Container Name: postgres
- Hostname: postgres
- Environment Variables:
POSTGRES_USER_FILE
: /run/secrets/db_userPOSTGRES_DB
: metabasePOSTGRES_PASSWORD_FILE
: /run/secrets/db_password
- Network: metanet1
- Secrets:
- db_password
- db_user
- Name: metanet1
- Driver: bridge
- File: db_password.txt
- File: db_user.txt
-
Make sure you have Docker and Docker Compose installed on your system.
-
Create the
db_password.txt
anddb_user.txt
files with your PostgreSQL password and username, respectively. -
Run the following command to start Metabase and PostgreSQL:
docker-compose up -d