docker.recipes

Metabase Analytics Platform

beginner

Metabase BI tool with PostgreSQL backend for self-service analytics.

Overview

Metabase is an open-source business intelligence platform that transforms raw data into interactive dashboards, reports, and visualizations without requiring SQL knowledge. Created in 2015, Metabase democratizes data analytics by providing a user-friendly interface that enables non-technical users to explore data, create charts, and build comprehensive dashboards through intuitive drag-and-drop functionality. Its self-service approach eliminates the bottleneck of waiting for technical teams to generate reports, empowering business users to answer their own questions with data. This configuration pairs Metabase with PostgreSQL as its application database, creating a robust analytics platform where PostgreSQL stores Metabase's metadata, user accounts, dashboard definitions, and cached query results. PostgreSQL's advanced SQL capabilities, ACID compliance, and excellent performance characteristics make it an ideal backend for Metabase's complex metadata operations and concurrent user sessions. The combination leverages PostgreSQL's reliability for storing critical business intelligence configurations while Metabase connects to your various data sources for analysis. This stack serves organizations seeking to implement self-service business intelligence without the complexity and cost of enterprise BI solutions like Tableau or Power BI. Small to medium businesses, startups with growing data needs, and teams requiring quick insights from multiple databases will find this combination particularly valuable. The setup provides enterprise-grade analytics capabilities while maintaining the flexibility to scale and integrate with existing data infrastructure.

Key Features

  • Interactive dashboard builder with 40+ visualization types including maps, funnels, and pivot tables
  • SQL query interface with visual query builder for users without SQL expertise
  • Automated email and Slack alerts based on data thresholds and schedules
  • Multi-database connectivity supporting MySQL, PostgreSQL, MongoDB, BigQuery, and 20+ other sources
  • User permission system with collection-based access control and row-level security
  • Embedded analytics with signed embedding for integrating dashboards into applications
  • PostgreSQL-powered metadata storage ensuring ACID compliance for user configurations and cached results
  • Mobile-responsive dashboards accessible on tablets and smartphones

Common Use Cases

  • 1SaaS companies tracking key metrics like MRR, churn rate, and user engagement across multiple databases
  • 2E-commerce businesses monitoring sales performance, inventory levels, and customer behavior analytics
  • 3Marketing teams analyzing campaign performance, lead conversion rates, and ROI across advertising platforms
  • 4Operations teams creating real-time dashboards for monitoring system performance and business KPIs
  • 5Financial reporting and budget tracking with automated monthly and quarterly report generation
  • 6Customer success teams monitoring product usage, support ticket trends, and user satisfaction metrics
  • 7Startups needing affordable business intelligence without licensing costs of enterprise BI tools

Prerequisites

  • Minimum 2GB RAM recommended for concurrent users and dashboard rendering performance
  • Port 3000 available for Metabase web interface access
  • Basic understanding of your data sources and connection credentials for database setup
  • 10GB+ disk space for PostgreSQL data storage and Metabase query caching
  • Network access to external databases you plan to connect for analysis
  • Docker and Docker Compose installed with ability to run persistent containers

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 postgres:
3 image: postgres:16-alpine
4 container_name: metabase-postgres
5 restart: unless-stopped
6 environment:
7 POSTGRES_USER: ${POSTGRES_USER:-metabase}
8 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-metabase}
9 POSTGRES_DB: ${POSTGRES_DB:-metabase}
10 volumes:
11 - postgres_data:/var/lib/postgresql/data
12 networks:
13 - metabase-network
14
15 metabase:
16 image: metabase/metabase:latest
17 container_name: metabase
18 restart: unless-stopped
19 ports:
20 - "${METABASE_PORT:-3000}:3000"
21 environment:
22 MB_DB_TYPE: postgres
23 MB_DB_DBNAME: ${POSTGRES_DB:-metabase}
24 MB_DB_PORT: 5432
25 MB_DB_USER: ${POSTGRES_USER:-metabase}
26 MB_DB_PASS: ${POSTGRES_PASSWORD:-metabase}
27 MB_DB_HOST: postgres
28 depends_on:
29 - postgres
30 networks:
31 - metabase-network
32
33volumes:
34 postgres_data:
35
36networks:
37 metabase-network:
38 driver: bridge

.env Template

.env
1# Metabase
2METABASE_PORT=3000
3POSTGRES_USER=metabase
4POSTGRES_PASSWORD=metabase
5POSTGRES_DB=metabase

Usage Notes

  1. 1Metabase at http://localhost:3000
  2. 2Complete setup wizard on first run
  3. 3Connect your data sources in settings
  4. 4Create dashboards with drag-and-drop

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

postgres
postgres:
  image: postgres:16-alpine
  container_name: metabase-postgres
  restart: unless-stopped
  environment:
    POSTGRES_USER: ${POSTGRES_USER:-metabase}
    POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-metabase}
    POSTGRES_DB: ${POSTGRES_DB:-metabase}
  volumes:
    - postgres_data:/var/lib/postgresql/data
  networks:
    - metabase-network
metabase
metabase:
  image: metabase/metabase:latest
  container_name: metabase
  restart: unless-stopped
  ports:
    - ${METABASE_PORT:-3000}:3000
  environment:
    MB_DB_TYPE: postgres
    MB_DB_DBNAME: ${POSTGRES_DB:-metabase}
    MB_DB_PORT: 5432
    MB_DB_USER: ${POSTGRES_USER:-metabase}
    MB_DB_PASS: ${POSTGRES_PASSWORD:-metabase}
    MB_DB_HOST: postgres
  depends_on:
    - postgres
  networks:
    - metabase-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 postgres:
5 image: postgres:16-alpine
6 container_name: metabase-postgres
7 restart: unless-stopped
8 environment:
9 POSTGRES_USER: ${POSTGRES_USER:-metabase}
10 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-metabase}
11 POSTGRES_DB: ${POSTGRES_DB:-metabase}
12 volumes:
13 - postgres_data:/var/lib/postgresql/data
14 networks:
15 - metabase-network
16
17 metabase:
18 image: metabase/metabase:latest
19 container_name: metabase
20 restart: unless-stopped
21 ports:
22 - "${METABASE_PORT:-3000}:3000"
23 environment:
24 MB_DB_TYPE: postgres
25 MB_DB_DBNAME: ${POSTGRES_DB:-metabase}
26 MB_DB_PORT: 5432
27 MB_DB_USER: ${POSTGRES_USER:-metabase}
28 MB_DB_PASS: ${POSTGRES_PASSWORD:-metabase}
29 MB_DB_HOST: postgres
30 depends_on:
31 - postgres
32 networks:
33 - metabase-network
34
35volumes:
36 postgres_data:
37
38networks:
39 metabase-network:
40 driver: bridge
41EOF
42
43# 2. Create the .env file
44cat > .env << 'EOF'
45# Metabase
46METABASE_PORT=3000
47POSTGRES_USER=metabase
48POSTGRES_PASSWORD=metabase
49POSTGRES_DB=metabase
50EOF
51
52# 3. Start the services
53docker compose up -d
54
55# 4. View logs
56docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/metabase-analytics/run | bash

Troubleshooting

  • Metabase shows 'Database connection failed' on startup: Check PostgreSQL container is fully initialized before Metabase starts, increase depends_on or add health checks
  • Out of memory errors during large query execution: Increase Docker container memory limits and adjust MB_JETTY_MAXTHREADS environment variable
  • Slow dashboard loading with multiple charts: Enable Metabase query caching and consider upgrading PostgreSQL shared_buffers configuration
  • Setup wizard redirects to localhost instead of server IP: Set MB_SITE_URL environment variable to your server's actual hostname or IP address
  • PostgreSQL connection pool exhausted errors: Adjust MB_DB_CONNECTION_TIMEOUT and ensure PostgreSQL max_connections setting accommodates concurrent users

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space