# Self-host Metabase with Postgres

> Metabase business intelligence with its own application data kept in a bundled Postgres database instead of the built in file, so dashboards and questions survive upgrades and scale past a single user. Create the admin on first open.

- Page: https://levelrail.com/templates/metabase-postgres/
- JSON: https://levelrail.com/templates/metabase-postgres.json
- Category: Analytics
- Licence: AGPL-3.0-or-later (Network copyleft (AGPL) license)
- Source: https://github.com/metabase/metabase
- Upstream docs: https://www.metabase.com/docs/latest/installation-and-operation/configuring-application-database

## Requirements
- Memory: about 1.5 GiB
- amd64: unknown, arm64: unknown
- Needs configuration before start: no
- Pinned image tag: 17.11-alpine

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| db | postgres | 17.11-alpine | none | pgdata -> /var/lib/postgresql/data |
| metabase | metabase/metabase | v0.65.4.1 | 3000 | none |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| db | POSTGRES_DB | preset |
| db | POSTGRES_PASSWORD | generated |
| db | POSTGRES_USER | preset |
| metabase | JAVA_OPTS | preset |
| metabase | MB_DB_DBNAME | preset |
| metabase | MB_DB_HOST | preset |
| metabase | MB_DB_PASS | generated |
| metabase | MB_DB_PORT | preset |
| metabase | MB_DB_TYPE | preset |
| metabase | MB_DB_USER | preset |

## Deploy

### CLI

```bash
levelrail-cli templates install metabase-postgres --name my-metabase-postgres
```

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain db=app.example.com.

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  https://levelrail.example.com/api/v1/service-templates/metabase-postgres/install \
  -d '{
    "name": "my-metabase-postgres"
  }'
```

Create a token in the dashboard first. Name, env and domains are the request fields.

## First run
1. Open the page, create the admin account, then connect the databases you want to explore.

## Questions

### Can I deploy Metabase with Postgres on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for Metabase with Postgres, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image postgres:17.11-alpine, metabase/metabase:v0.65.4.1 is what you deploy there.

Self-host Metabase with Postgres, Metabase with Postgres docker compose file, deploy Metabase with Postgres on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
