How to Install Metabase on Ubuntu 24 with Docker
Metabase serves as a free, open-source business intelligence tool that allows teams to build dashboards, visualisations, and reports without delving into SQL, while also accommodating advanced users who prefer SQL queries. Owing to its user-friendly design and strong visualisation features, Metabase has gained traction among organisations eager to make prompt, data-driven choices. This guide details the process of installing Metabase on Ubuntu 24 using Docker, including the full configuration steps, common troubleshooting methods, and recommended practices for deployment in production environments.
Benefits of Docker for Metabase Installation
Installing Metabase via Docker presents numerous benefits in comparison to conventional methods. Docker containers ensure environmental consistency, isolation, and simplify dependency management. The official Metabase Docker image is equipped with all required components, thus circumventing potential version conflicts and diminishing setup intricacies.
This table illustrates how Docker stands up against other installation techniques:
Installation Approach | Time Required | Maintenance Level | Scalability | Isolation Quality |
---|---|---|---|---|
Docker | 5-10 minutes | Low | High | Excellent |
JAR File | 15-30 minutes | Medium | Medium | Low |
Source Build | 30-60 minutes | High | High | Low |
System Requirements and Prerequisites
Ensure that your Ubuntu 24 system satisfies the following prerequisites before proceeding with the Metabase installation:
- Ubuntu 24.04 LTS with sudo access
- A minimum of 2GB RAM (4GB is advisable for production use)
- At least 2GB of free disk space
- Docker and Docker Compose must be installed
- Internet access to fetch Docker images
First, refresh your system and install Docker if it isn’t already available:
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 then back in for the group changes to apply, then check your Docker installation status:
docker --version
docker-compose --version
Metabase Installation Steps
The easiest method is to utilise Docker Compose for organising Metabase alongside its database. Begin by creating a specific directory for your Metabase setup:
mkdir ~/metabase-docker
cd ~/metabase-docker
Next, generate a file named docker-compose.yml
containing 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:
Substitute secure_password_here
with a solid password and modify the timezone as necessary. To initiate the services, run:
docker-compose up -d
Keep an eye on the startup procedure:
docker-compose logs -f metabase
The initial startup phase may take 2-3 minutes as Metabase sets up its database schema. Once you observe "Metabase Initialization COMPLETE" in the logs, you can access the web interface via http://your-server-ip:3000
.
Configuration and First Setup
Your first visit to Metabase will trigger the setup wizard. You'll need to configure:
- Your admin account details
- Information about your organisation
- Connections to data sources
- Preferences for usage tracking
For environments intended for production, consider these additional settings 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: [email protected]
MB_EMAIL_SMTP_PASSWORD: your-app-password
JAVA_OPTS: "-Xmx2g"
Configuring SSL with Nginx as a Reverse Proxy
For production scenarios, it’s advisable to implement SSL through Nginx as a reverse proxy. Start by installing Nginx and Certbot:
sudo apt install nginx certbot python3-certbot-nginx -y
Create a configuration file for Nginx:
sudo nano /etc/nginx/sites-available/metabase
Add the following 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 retrieve your 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
Connecting to Different Databases
Metabase is compatible with various databases. Below are connection examples for some of the widely used options:
MySQL/MariaDB:
- Host: your-mysql-server.com
- Port: 3306
- Name of Database: your_database
- Username: metabase_user
- Extra JDBC options:
useSSL=true&serverTimezone=UTC
PostgreSQL:
- Host: your-postgres-server.com
- Port: 5432
- Name of Database: your_database
- Schema: public (or another specific schema)
- SSL Mode: require (recommended for production)
MongoDB:
- Host: your-mongo-server.com
- Port: 27017
- Name of Database: your_database
- Authentication Database: admin
- Additional connection string options:
?ssl=true&authMechanism=SCRAM-SHA-1
Optimising Performance and Scaling
To enhance Metabase's performance for production use, consider implementing the following configurations:
Java Memory Configurations:
environment:
JAVA_OPTS: -Xmx4g -Xms1g -XX:+UseG1GC -XX:MaxGCPauseMillis=100
Database Query Caching:
Enable query caching in the Metabase Admin settings to alleviate database strain effectively. Determine the appropriate cache TTL based on your data update frequency.
Connection Pool Adjustments:
environment:
MB_DB_CONNECTION_TIMEOUT_MS: 10000
MB_JDBC_DATA_WAREHOUSE_MAX_CONNECTION_POOL_SIZE: 15
Performance testing indicates notable improvements when configurations are optimised:
Configuration
Dashboard Load Duration
Query Response Duration
Simultaneous Users
Default Settings
3-5 seconds
2-8 seconds
10-15
Optimised
1-2 seconds
0.5-3 seconds
50-75
Troubleshooting Common Issues
Container Fails to Start:
Examine Docker logs to pinpoint specific error messages:
docker-compose logs metabase
docker-compose logs postgres
Frequent issues arise from inadequate memory, port conflicts, or problems with database connectivity.
Database Connection Problems:
Ensure your network connectivity and login credentials are correct:
# Test database reachability from the container
docker exec -it metabase bash
telnet postgres 5432
Performance Slowdowns:
Keep an eye on resource consumption and fine-tune your queries:
docker stats metabase
docker exec -it metabase-postgres psql -U metabase -c "SELECT * FROM pg_stat_activity;"
Memory Problems:
Increase Java heap size while monitoring garbage collection activities:
environment:
JAVA_OPTS: -Xmx4g -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
Backup and Restoration Techniques
Conducting regular backups is vital for any Metabase installation in a production setting. Draft backup scripts for both application data and the 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
Back up PostgreSQL database
docker exec metabase-postgres pg_dump -U metabase metabase > $BACKUP_DIR/metabasedb$DATE.sql
Back up Metabase application data
docker run --rm -v metabase-docker_metabase-data:/data -v $BACKUP_DIR:/backup alpine tar czf /backup/metabasedata$DATE.tar.gz -C /data .
Retain only the last 7 days of backups
find $BACKUPDIR -name "metabase*" -mtime +7 -delete
To restore from backup, do the following:
# Stop services
docker-compose down
Restore the 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 again
docker-compose up -d
Best Practices for Security
Adopt the following security strategies for your production builds:
- Utilise strong and unique passwords for all accounts
- Activate SSL/TLS to secure all connections
- Implement firewall rules to restrict network access
- Keep base images updated frequently for security patches
- Enable audit logging for compliance purposes
Set firewall rules as follows:
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw deny 3000/tcp
sudo ufw enable
Establish automatic security updates:
# Schedule Docker image updates 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 Capabilities with External Tools
Metabase allows seamless integration with an array of external services:
Single Sign-On (SSO):
Set up SAML or LDAP authentication for enterprise needs. Use 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 Notifications:
Configure Slack notifications for updates and alerts on dashboards through Metabase’s integrated Slack functionality.
API Utilisation:
Metabase offers REST APIs for programmatic data access. Generate API keys in the admin panel for automation:
curl -X GET \
"http://your-metabase:3000/api/dashboard/1" \
-H "X-Metabase-Session: your-session-token"
This installation method establishes a solid, scalable framework for business intelligence processes. The Docker approach simplifies upkeep, while providing room for further customisation and expansion as your analytics requirements evolve. For more detailed configuration options and advanced features, refer to the official Metabase documentation.

This article draws upon insights and content from a variety of online sources. We acknowledge and value the contributions of all original authors, publishers, and websites. While every effort has been made to appropriately credit source materials, any unintentional oversight or omission does not imply copyright infringement. All trademarks, logos, and images mentioned remain the property of their respective owners. If you believe any content used in this article infringes upon your copyright, please reach out to us immediately for review and prompt action.
This article is designed for informational and educational use and does not infringe copyright. If any copyrighted material has been utilised without appropriate credit or in contravention of copyright laws, it is unintentional and we will promptly rectify this upon notification. Please be advised that republishing, redistributing, or reproducing parts or whole of the contents in any format is prohibited without explicit written consent from the author and website proprietor. For permission inquiries or further questions, please contact us.