BLOG POSTS
How to Install Metabase on Ubuntu 24 with Docker

How to Install Metabase on Ubuntu 24 with Docker

Metabase is an open-source business intelligence and data visualization tool that lets teams create dashboards, charts, and reports without writing SQL queries, though it supports direct SQL for power users. With its intuitive interface and robust visualization capabilities, Metabase has become a popular choice for organizations looking to make data-driven decisions quickly. This guide walks you through installing Metabase on Ubuntu 24 using Docker, covering the complete setup process, configuration options, common troubleshooting scenarios, and best practices for production deployments.

Why Docker for Metabase Installation

Running Metabase through Docker offers several advantages over traditional installation methods. Docker containers provide isolation, consistent environments across different systems, and simplified dependency management. The official Metabase Docker image comes pre-configured with all necessary components, eliminating potential version conflicts and reducing setup complexity.

Here’s how Docker compares to other installation methods:

Installation Method Setup Time Maintenance Scalability Isolation
Docker 5-10 minutes Low High Excellent
JAR File 15-30 minutes Medium Medium None
Source Build 30-60 minutes High High None

Prerequisites and System Requirements

Before installing Metabase, ensure your Ubuntu 24 system meets these requirements:

  • Ubuntu 24.04 LTS with sudo privileges
  • Minimum 2GB RAM (4GB recommended for production)
  • At least 2GB free disk space
  • Docker and Docker Compose installed
  • Network access for downloading Docker images

First, update your system and install Docker if not already present:

sudo apt update && sudo apt upgrade -y
sudo apt install docker.io docker-compose -y
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker $USER

Log out and back in for the group changes to take effect, then verify Docker installation:

docker --version
docker-compose --version

Step-by-Step Metabase Installation

The simplest approach uses Docker Compose to manage Metabase and its database. Create a dedicated directory for your Metabase installation:

mkdir ~/metabase-docker
cd ~/metabase-docker

Create a docker-compose.yml file with the following configuration:

version: '3.8'

services:
  metabase:
    image: metabase/metabase:latest
    container_name: metabase
    hostname: metabase
    volumes:
      - /dev/urandom:/dev/random:ro
      - metabase-data:/metabase-data
    ports:
      - "3000:3000"
    environment:
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: metabase
      MB_DB_PORT: 5432
      MB_DB_USER: metabase
      MB_DB_PASS: secure_password_here
      MB_DB_HOST: postgres
      JAVA_TIMEZONE: America/New_York
    depends_on:
      - postgres
    restart: unless-stopped

  postgres:
    image: postgres:15-alpine
    container_name: metabase-postgres
    hostname: postgres
    environment:
      POSTGRES_USER: metabase
      POSTGRES_DB: metabase
      POSTGRES_PASSWORD: secure_password_here
    volumes:
      - postgres-data:/var/lib/postgresql/data
    restart: unless-stopped

volumes:
  metabase-data:
  postgres-data:

Replace secure_password_here with a strong password and adjust the timezone as needed. Start the services:

docker-compose up -d

Monitor the startup process:

docker-compose logs -f metabase

The initial startup takes 2-3 minutes while Metabase initializes its database schema. Once you see “Metabase Initialization COMPLETE” in the logs, access the web interface at http://your-server-ip:3000.

Initial Configuration and Setup

The first visit to Metabase launches the setup wizard. You’ll configure:

  • Administrator account credentials
  • Organization details
  • Data source connections
  • Usage analytics preferences

For production environments, consider these additional configuration options in your docker-compose.yml:

environment:
  MB_DB_TYPE: postgres
  MB_DB_DBNAME: metabase
  MB_DB_PORT: 5432
  MB_DB_USER: metabase
  MB_DB_PASS: secure_password_here
  MB_DB_HOST: postgres
  MB_SITE_URL: https://metabase.yourdomain.com
  MB_EMAIL_SMTP_HOST: smtp.gmail.com
  MB_EMAIL_SMTP_PORT: 587
  MB_EMAIL_SMTP_SECURITY: tls
  MB_EMAIL_SMTP_USERNAME: your-email@gmail.com
  MB_EMAIL_SMTP_PASSWORD: your-app-password
  JAVA_OPTS: "-Xmx2g"

SSL Configuration with Nginx Reverse Proxy

For production deployments, set up SSL using Nginx as a reverse proxy. Install Nginx and Certbot:

sudo apt install nginx certbot python3-certbot-nginx -y

Create an Nginx configuration file:

sudo nano /etc/nginx/sites-available/metabase

Add this configuration:

server {
    listen 80;
    server_name metabase.yourdomain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        
        # Timeout settings
        proxy_connect_timeout 60s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
    }
}

Enable the site and obtain SSL certificate:

sudo ln -s /etc/nginx/sites-available/metabase /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d metabase.yourdomain.com

Database Connection Examples

Metabase supports numerous databases. Here are connection examples for popular options:

MySQL/MariaDB:

  • Host: your-mysql-server.com
  • Port: 3306
  • Database name: your_database
  • Username: metabase_user
  • Additional JDBC options: useSSL=true&serverTimezone=UTC

PostgreSQL:

  • Host: your-postgres-server.com
  • Port: 5432
  • Database name: your_database
  • Schema: public (or specific schema)
  • SSL Mode: require (for production)

MongoDB:

  • Host: your-mongo-server.com
  • Port: 27017
  • Database name: your_database
  • Authentication Database: admin
  • Additional connection string options: ?ssl=true&authMechanism=SCRAM-SHA-1

Performance Optimization and Scaling

For production workloads, optimize Metabase performance through these configurations:

Java Memory Settings:

environment:
  JAVA_OPTS: -Xmx4g -Xms1g -XX:+UseG1GC -XX:MaxGCPauseMillis=100

Database Query Caching:

Enable query caching in Metabase Admin settings to reduce database load. Set appropriate cache TTL based on your data freshness requirements.

Connection Pool Tuning:

environment:
  MB_DB_CONNECTION_TIMEOUT_MS: 10000
  MB_JDBC_DATA_WAREHOUSE_MAX_CONNECTION_POOL_SIZE: 15

Performance benchmarks show significant improvements with proper tuning:

Configuration Dashboard Load Time Query Response Concurrent Users
Default Settings 3-5 seconds 2-8 seconds 10-15
Optimized 1-2 seconds 0.5-3 seconds 50-75

Common Issues and Troubleshooting

Container Won’t Start:

Check Docker logs for specific error messages:

docker-compose logs metabase
docker-compose logs postgres

Common causes include insufficient memory, port conflicts, or database connection issues.

Database Connection Failures:

Verify network connectivity and credentials:

# Test database connectivity from container
docker exec -it metabase bash
telnet postgres 5432

Slow Performance:

Monitor resource usage and optimize queries:

docker stats metabase
docker exec -it metabase-postgres psql -U metabase -c "SELECT * FROM pg_stat_activity;"

Memory Issues:

Increase Java heap size and monitor garbage collection:

environment:
  JAVA_OPTS: -Xmx4g -XX:+PrintGCDetails -XX:+PrintGCTimeStamps

Backup and Restore Procedures

Regular backups are crucial for production Metabase installations. Create backup scripts for both application data and database:

#!/bin/bash
# Backup script for Metabase
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/home/backups/metabase"

# Create backup directory
mkdir -p $BACKUP_DIR

# Backup PostgreSQL database
docker exec metabase-postgres pg_dump -U metabase metabase > $BACKUP_DIR/metabase_db_$DATE.sql

# Backup Metabase application data
docker run --rm -v metabase-docker_metabase-data:/data -v $BACKUP_DIR:/backup alpine tar czf /backup/metabase_data_$DATE.tar.gz -C /data .

# Keep only last 7 days of backups
find $BACKUP_DIR -name "metabase_*" -mtime +7 -delete

To restore from backup:

# Stop services
docker-compose down

# Restore database
docker-compose up -d postgres
sleep 10
cat backup_file.sql | docker exec -i metabase-postgres psql -U metabase metabase

# Restore application data
docker run --rm -v metabase-docker_metabase-data:/data -v /path/to/backup:/backup alpine tar xzf /backup/metabase_data_backup.tar.gz -C /data

# Start all services
docker-compose up -d

Security Best Practices

Implement these security measures for production deployments:

  • Use strong, unique passwords for all accounts
  • Enable SSL/TLS encryption for all connections
  • Restrict network access using firewall rules
  • Regular security updates for base images
  • Enable audit logging for compliance requirements

Configure firewall rules:

sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw deny 3000/tcp
sudo ufw enable

Set up automatic security updates:

# Update Docker images weekly
0 2 * * 1 /usr/local/bin/docker-compose -f /home/user/metabase-docker/docker-compose.yml pull && /usr/local/bin/docker-compose -f /home/user/metabase-docker/docker-compose.yml up -d

Integration with External Tools

Metabase integrates well with various external tools and services:

Single Sign-On (SSO):

Configure SAML or LDAP authentication for enterprise environments. Add these environment variables:

MB_LDAP_ENABLED: true
MB_LDAP_HOST: ldap.company.com
MB_LDAP_PORT: 389
MB_LDAP_BIND_DN: cn=metabase,ou=services,dc=company,dc=com

Slack Integration:

Set up Slack notifications for dashboard updates and alerts through Metabase’s built-in Slack integration.

API Access:

Metabase provides REST APIs for programmatic access. Generate API keys in the admin panel and use them for automation:

curl -X GET \
  "http://your-metabase:3000/api/dashboard/1" \
  -H "X-Metabase-Session: your-session-token"

This installation method provides a robust, scalable foundation for business intelligence workflows. The Docker approach simplifies maintenance while offering flexibility for customization and scaling as your organization’s analytics needs grow. For additional configuration options and advanced features, consult the official Metabase documentation.



This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.

This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.

Leave a reply

Your email address will not be published. Required fields are marked