Metabase with PostgreSQL on Debian 12 (Docker Compose + Nginx + SSL)

Metabase is an open-source business intelligence (BI) and analytics platform that allows teams to easily explore, visualize, and share data — without writing complex SQL queries. With an intuitive web-based interface, users can build dashboards, charts, and reports directly from databases like PostgreSQL, MySQL, or MongoDB, helping organizations make informed, data-driven decisions.

Running Metabase on Debian 12 (Bookworm) with PostgreSQL provides a stable, secure, and long-term supported environment. Debian 12 includes systemd 252, OpenSSL 3, and up-to-date Docker packages, making it an excellent base for deploying Metabase in production with Docker Compose, Nginx reverse proxy, and SSL encryption.


Architecture Overview

LayerComponentRole
OSDebian 12 (Bookworm)Stable, long-term supported Linux base
Container RuntimeDocker Engine + ComposeOrchestrates Metabase and PostgreSQL containers
DatabasePostgreSQL 15Stores dashboards, users, queries, and configuration data
ApplicationMetabase ServerProvides web-based BI dashboards and data visualization tools
Reverse ProxyNginx (optional)Manages HTTPS, compression, caching, and routing
TLSLet’s Encrypt / PKIEnables secure HTTPS access for users and admins

Why Use Metabase?

  • Self-hosted BI platform – no vendor lock-in, full control of your data.
  • User-friendly interface – create dashboards and queries with no code.
  • SQL-ready – advanced users can write and optimize custom SQL.
  • Multi-database support – connect PostgreSQL, MySQL, BigQuery, and more.
  • Free and open-source – deploy anywhere with no licensing cost.
  • Enterprise extensions – SSO, advanced permissions, and auditing available in paid editions.

Metabase vs Other BI Tools

Feature/CapabilityMetabase (Self-hosted)Tableau (Cloud)Power BI (Microsoft)Apache Superset (Self-hosted)
HostingSelf-hosted (Docker)SaaS / DesktopSaaS / Windows onlySelf-hosted (Docker)
CostFree, open-sourceSubscriptionSubscriptionFree, open-source
Database supportBroad (SQL sources)Very broadMS ecosystemBroad (SQL sources)
Ease of useVery easyModerateModerateDeveloper-oriented
Ideal forTeams, SMBs, startupsLarge orgsEnterprisesEngineers and analysts

Metabase is best suited for teams and organizations that want a self-hosted analytics solution that’s simple to use yet powerful enough for complex insights.


Security & Best Practices

  • Deploy behind Nginx with SSL (HTTPS) for secure access.
  • Store PostgreSQL credentials securely in environment variables or Docker secrets.
  • Use a dedicated PostgreSQL user with limited privileges for Metabase.
  • Restrict PostgreSQL to internal Docker networks only.
  • Automate PostgreSQL backups using pg_dump or containerized backup jobs.
  • Keep Debian, Docker, and Metabase images updated.
  • Enforce strong passwords and configure Metabase role-based permissions.
  • Automate SSL renewals using Certbot or Traefik ACME integration.

Typical Use Cases

  • Business dashboards and performance reports.
  • Marketing and sales analytics using PostgreSQL data.
  • KPI tracking for startups and enterprises.
  • Data exploration for non-technical users.
  • Internal analytics for SaaS, finance, and e-commerce platforms.

Deploying Metabase with PostgreSQL on Debian 12 provides a powerful, secure, and scalable analytics platform that allows your organization to turn data into actionable insights — all while maintaining full ownership and control of your infrastructure.


Step 1: Create a Server Instance on Shape.Host

Log in to your Shape.Host account.

Click Create → Instance.

Shape.host Resources dashboard with Create > Instance highlighted.

Choose your preferred location.

Shape.host instance form with the data center location selector highlighted.

Select a plan with at least 2 CPUs, 4 GB RAM, and 20 GB SSD.

Choose Debian 12 (64-bit) as the operating system.

Shape.host instance form with the operating system image selector highlighted.

Click Create Instance.

Shape.host instance form with the Create Instance button highlighted.

Once the instance is ready, copy your public IP address from the Resources section.

Shape.host Resources dashboard with the server IP address highlighted.

Step 2: Connect to Your Server

Use SSH to connect:

  • Linux/macOS: ssh root@your_server_ip
  • Windows (PuTTY):
    1. Open PuTTY.
    2. Enter your server IP and click Open.
    3. Log in as root.

Step 3: Install Docker and Docker Compose

Update system packages:

apt update
Terminal showing APT package management commands and output.

Install required dependencies:

apt install ca-certificates curl gnupg lsb-release

These packages allow Debian to securely download and verify Docker packages.

Terminal showing APT package management commands and output.

Create a directory for Docker’s GPG key:

mkdir -p /etc/apt/keyrings

Download and save Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc

Add the Docker repository to your APT sources:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
> /etc/apt/sources.list.d/docker.list

Update the package index again:

apt update
Terminal showing APT package management commands and output.

Install Docker Engine, CLI, container runtime, and Compose plugin:

apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Terminal showing APT package management commands and output.

Enable Docker to start on boot:

systemctl enable docker

Start Docker:

systemctl start docker

Verify Docker installation:

docker --version
docker compose version

Step 4: Create the Metabase Project Directory

Create a working directory for your containers:

mkdir -p /opt/metabase
cd /opt/metabase
Terminal showing systemd service management commands or output.

Step 5: Create Docker Compose Configuration

Open the configuration file:

nano docker-compose.yml

Paste the following content:

version: "3.9"

services:
  db:
    image: postgres:15
    container_name: metabase-postgres
    restart: always
    environment:
      POSTGRES_USER: metabase
      POSTGRES_PASSWORD: StrongPassword123!
      POSTGRES_DB: metabase
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  metabase:
    image: metabase/metabase:latest
    container_name: metabase-app
    restart: always
    ports:
      - "3000:3000"
    environment:
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: metabase
      MB_DB_PORT: 5432
      MB_DB_USER: metabase
      MB_DB_PASS: StrongPassword123!
      MB_DB_HOST: db
    depends_on:
      - db
    volumes:
      - mb-data:/metabase-data

volumes:
  pgdata:
  mb-data:

Explanation

ComponentDescription
dbPostgreSQL 15 container storing all Metabase configuration data.
metabaseThe Metabase web application, exposed on port 3000.
volumesPersistent storage for database and app data to survive container restarts.

Save and exit (CTRL + O, then CTRL + X).

Terminal showing application configuration settings.

Step 6: Deploy Metabase

Download the required Docker images:

docker compose pull
Terminal showing container image download progress.

Start Metabase and PostgreSQL containers:

docker compose up -d
Terminal showing Docker Compose image downloads and container startup output.

Verify both services are running:

docker compose ps

If both containers show Up, your Metabase stack is now live.

Terminal showing docker commands or output during Deploy Metabase.

Step 7: Access Metabase

If you’re not using Nginx, open Metabase directly via:

http://YOUR_SERVER_IP:3000

If you configured a domain and SSL, open:

https://metabase.example.com

You’ll see the Metabase Setup Wizard — create your admin account, connect your data sources, and start building dashboards.

Welcome to Metabase

The welcome page indicates that everything is working.
Click “Let’s get started” to begin the initial configuration process.

Metabase getting started screen.

Choose Your Language

Metabase will ask for your preferred interface language.

  • Select English (or any language you prefer).
  • Click Next to continue.
Metabase setup interface.

Administrator Account Setup

You’ll now create the first admin account for your Metabase instance.

Fill out the fields as follows:

  • First name: Andrei
  • Last name: Gh
  • Email: contact@shape.host
  • Company or team name: ShapeHost
  • Password: Choose a secure password
  • Confirm password: Re-enter your password

After completing the form, click Next.

Metabase setup interface.

Usage Purpose

Metabase will ask how you plan to use it.
Select:

Self-service analytics for my own company

This option helps configure Metabase for your internal analytics environment.
Click Next to proceed.

Metabase setup interface.

Database Connection

In this step, you can connect Metabase to a data source.

Since PostgreSQL was already configured earlier, you have two options:

  • Connect to your PostgreSQL database now by selecting PostgreSQL and entering your credentials.
    or
  • Click Continue with sample data to explore Metabase first using its built-in demo dataset.

You can always connect your PostgreSQL database later from the Metabase Admin Panel:
Admin → Databases → Add Database

Metabase setup interface.

Data Collection Preferences

Metabase will ask whether you want to share anonymous usage data to help improve the software.
You can either:

  • Leave it enabled (default), or
  • Turn it off for privacy.

Click Finish to finalize the setup.

Metabase setup completion screen with data collection preferences.

Dashboard Overview

Screenshot 7 – Metabase Home Page

Once setup is complete, you’ll be redirected to the main dashboard.
From here, you can:

  • Explore the sample dashboards and charts
  • Connect to your PostgreSQL data
  • Create custom dashboards, reports, and visualizations
  • Manage data models and metrics from the left sidebar
Metabase home page showing data exploration and getting started options.

You installed Metabase with PostgreSQL on Debian 12 using Docker Compose.
You now have a robust, containerized analytics platform ready for dashboards, charts, and business insights.

For optimal uptime and performance, host your Metabase instance on a Shape.Host Cloud VPS, offering high availability, SSD storage, and full root access.