
Metabase is an open-source business intelligence (BI) tool that lets you explore data, build dashboards, and share reports from a web browser. Teams often self-host Metabase because it connects to common databases such as PostgreSQL, MySQL, MariaDB, and SQL Server.
This article explains how to deploy Metabase on a Linux server using Docker Compose, with a PostgreSQL backend and Traefik providing automatic HTTPS. It covers directory and environment variable setup, deployment, and completing the initial administrator setup through the web interface.
Before you begin, you need to:
metabase.example.com).Metabase stores its application data, such as users, dashboards, and saved questions, in PostgreSQL. This section creates the project directory and the environment file that the Compose stack shares.
Create the project directory.
Navigate to the project directory.
Generate a random key that Metabase uses to encrypt stored data-source credentials.
Save the output for use in the environment file.
Create an environment file to store configuration variables.
Add the following configuration. Replace YOUR_DB_PASSWORD with a strong password, YOUR_ENCRYPTION_KEY with the output from the previous openssl command, metabase.example.com with your domain name, and ADMIN_EMAIL with a deliverable email address for Let's Encrypt renewal notices.
Save and close the file.
The deployment stack consists of Traefik for reverse proxy and certificate management, plus the Metabase and PostgreSQL containers on a shared bridge network. This configuration uses the official Metabase container image version v0.50.21.
Create the Docker Compose manifest.
Add the following content.
Save and close the file.
In the above manifest:
postgres: Runs PostgreSQL 16 as the database that stores Metabase's users, dashboards, and saved questions.metabase: Runs the Metabase application server. It starts only after PostgreSQL reports healthy, and its Traefik labels register it for automatic HTTPS on the configured DOMAIN.traefik: Serves as the reverse proxy and TLS termination point. It listens on ports 80 and 443, redirects HTTP to HTTPS, and provisions Let's Encrypt certificates.mem_limit and logging cap each container's memory and rotate its logs, preventing either from exhausting the server's resources.Launch the containers.
Verify that the services are running.
The output displays all three containers in an Up state, with a healthy status shown for metabase-postgres and metabase once their health checks pass.
Query the Metabase health endpoint through your domain.
Your output should be similar to the one below:
View the service logs to confirm Metabase loaded the configuration successfully.
The output displays PostgreSQL accepting connections and Metabase completing its startup migrations, which take one to two minutes. Press Ctrl + C to stop following the logs once the service reports that it has started.
For more information on managing a Docker Compose stack, see the How to Use Docker Compose article.
Open Metabase in a browser and complete the first-run wizard.
Open your domain over HTTPS in a browser. Replace metabase.example.com with your domain.
Select your preferred language.
Create the initial administrator account by entering your name, email address, and password.
When prompted to add your first data source, configure one now or skip and add it later.
Setup is now complete, and Metabase is ready to use. Any databases you connect through the interface stay separate from the PostgreSQL container, which stores only Metabase's own metadata.
You have deployed Metabase on a Linux server using Docker Compose with Traefik for automatic HTTPS and PostgreSQL for persistent data storage. You can now connect additional databases and build dashboards to explore your data. For more information, visit the official Metabase documentation.
0 Comments
Be the first to comment and share your perspective with the community.