Install Metabase Inside Docker Container in Linux

Install Metabase Inside Docker Container in Linux

Metabase is a business intelligence and analytics tool for visualizing and analyzing data. It provides a web interface for users to explore data, generate charts and graphs, and create dashboards and reports.

This tutorial explains how to install Metabase inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

You also need to have a running PostgreSQL container. Instructions can be found in the post.

Install Metabase

Before starting, create metabase database:

docker exec -it postgresql psql -U postgres -c "CREATE DATABASE metabase"
  • Host network

Run the following command to create a container for Metabase that uses host network:

docker run -d --name=metabase --restart=always --network=host \
    -e MB_DB_TYPE=postgres \
    -e MB_DB_USER=postgres \
    -e MB_DB_PASS=pwd123 \
    -e MB_DB_DBNAME=metabase \
    -e MB_DB_PORT=5432 \
    -e MB_DB_HOST=127.0.0.1 \
    metabase/metabase

PostgreSQL container should run on host network as well.

  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, Metabase service is listening on port 3000. It can be changed with -p option.

docker network create app-net
docker run -d --name=metabase --restart=always --network=app-net \
    -p 8080:3000 \
    -e MB_DB_TYPE=postgres \
    -e MB_DB_USER=postgres \
    -e MB_DB_PASS=pwd123 \
    -e MB_DB_DBNAME=metabase \
    -e MB_DB_PORT=5432 \
    -e MB_DB_HOST=postgresql \
    metabase/metabase

PostgreSQL container should run on the same user-defined bridge network as well.

Notes:

  • The MB_DB_USER and MB_DB_PASS can be used to specify PostgreSQL credentials.
  • When user-defined bridge network is used, don't forget to change MB_DB_HOST. It contains PostgreSQL container name.

Testing Metabase

Open a web browser and go to http://<IP_ADDRESS>:3000, where <IP_ADDRESS> is the IP address of the system. For the first time, you will be asked to create the administrator account. After that, you will be redirected to the dashboard.

Metabase Inside Docker Container in Linux

Uninstall Metabase

To completely remove Metabase, remove its container:

docker rm --force metabase

Remove Metabase image:

docker rmi metabase/metabase

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.