Understanding the Process of Running Metabase on Docker for the First Time 📊🐋
Tags: metabase, datascience, opensource, docker
Published: 2023-11-18 03:32:18

## {% details Outlines %}
- [Open Source Quick Start 🌟](#open-source-quick-start)
- [Setting Up Metabase 🛠️](#setting-up-metabase)
  - [Setting Up An Admin Account 🛠️](#setting-up-an-admin-account)
  - [Gathering Database Info 🛠️](#gathering-database-info)
  - [Connect to Database 🛠️](#connect-to-database)
  - [Usage Data Preferences 🛠️](#usage-data-preferences)
  - [Staying in Touch 🛠️](#staying-in-touch)
- [Metabase Home Page 💻](#metabase-home-page)
- [Asking Metabase Question 🙋‍♂️](#asking-metabase-question)
- [Filtering Data 🔍](#filtering-data)
- [Previewing Results 👓](#previewing-results)
- [Summarizing Data 📊](#summarizing-data)
- [Grouping Results 🤝](#grouping-results)
- [Changing the Visualization 🌆](#changing-the-visualization)
- [References 📚](#references)
- [Connect with Me 👨‍💻](#connect-with-me)
{% enddetails %}

## Open Source Quick Start 🌟

Welcome to your first-time setup guide for running the Open Source version of Metabase using Docker. This guide will help you get Metabase up and running locally on your system.

> Note: Assuming you have Docker installed and running. Please click on any image to zoom in.

Here, I'm using [Docker Desktop WSL 2 backend on Windows with distro integration](https://docs.docker.com/desktop/wsl/).

1. Get the latest Docker image:
    [![docker pull](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxkt8auhxgjthpajysac.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxkt8auhxgjthpajysac.png)
    ```bash
    docker pull metabase/metabase:latest
    ```
    {% details 🔎 command explanation %}
    - `docker pull`: This is the command used to download ("pull") a Docker image from a registry.
    - `metabase/metabase`: This specifies the name of the Docker image. The part before the slash (`metabase`) typically denotes the Docker Hub username or organization, while the part after the slash (`metabase`) is the repository name of the image.
    - `:latest`: This is a tag that specifies which version of the image you want to pull. The `latest` tag is often used to denote the most recent stable version of an image.

    So, in short, this command pulls the most recent stable version of the Metabase image from the official Metabase repository on Docker Hub.
    {% enddetails %}

2. Start the Metabase container anywhere and go to `http://localhost:3000`:
    [![docker run](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2otyulysnl2idrdcqs4.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2otyulysnl2idrdcqs4.png)
    ```bash
    docker run -d -p 3000:3000 --name metabase metabase/metabase
    ```
    {% details 🔎 command explanation %}
    - `docker run`: This is the command to create and start a new container.
    - `-d`: Run the container in detached mode, meaning it runs in the background and doesn't block the current shell.
    - `-p 3000:3000`: Map port 3000 of the host to port 3000 in the container. This allows you to access the application running in the container via `localhost:3000` on your host machine.
    - `--name metabase`: Assign the name `metabase` to the container. This name can be used to reference the container in subsequent commands, instead of using the container's ID.
    - `metabase/metabase`: The image to use to create the container. This specifies that Docker should use the `metabase/metabase` image from Docker Hub, and if it isn't available locally, Docker will pull it from the registry first.

    In summary, the command starts a new container from the `metabase/metabase` image, named `metabase`, running in the background, with the container's port 3000 accessible via port 3000 on the host machine.
    {% enddetails %}

3. Stop and remove the Metabase container. If you need to use the Metabase container again later just run the `docker stop metabase` command only:
    ```bash
    docker stop metabase && docker rm metabase
    ```
    {% details 🔎 command explanation %}
    - `docker stop metabase`: This command stops the running container named `metabase`.
    - `&&`: This is a shell operator that allows you to execute a second command only if the first command (`docker stop metabase`) succeeds.
    - `docker rm metabase`: This command removes the container named `metabase` freeing up resources and allowing you to start a fresh container with the same name without conflict. Containers need to be stopped before they can be removed.

    Running this command will turn off the Metabase service running in the Docker container and then remove the container.
    {% enddetails %}

4. To start the Metabase again without removing them beforehand:
    ```bash
    docker start metabase
    ```
    {% details 🔎 command explanation %}
    - `docker start metabase`: This command will start the existing container named `metabase`. This is useful when you have a container that you've stopped and want to run again without setting it up from scratch.

    By using `docker start`, you preserve the container's state and any data that might be stored within it between stop and start operations. This is often preferred for applications that store configuration or data that you want to retain across sessions.
    {% enddetails %}

## Setting Up Metabase 🛠️

[![setup metabase](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2otyulysnl2idrdcqs4.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2otyulysnl2idrdcqs4.png)

### Setting Up An Admin Account 🛠️

The initial step involves setting up an admin account. Conveniently, the account you establish when you first install Metabase automatically has admin privileges. Since we are presumably deploying for development and not production, it's acceptable if you don't remember the password for this account right away. However, if this were a production server, extreme caution would be necessary to remember this password as it grants access to add other users, connect to databases, set up email, and more. Additional admin accounts can also be created at a later stage.

For the time being, we'll create an account for personal use to navigate through Metabase. Enter your details, and when you're prepared to proceed, click the 'Next' button.

[![admin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n63c5ul2t8q2crrnp4hq.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n63c5ul2t8q2crrnp4hq.gif)

### Gathering Database Info 🛠️

At this stage, you'll need to compile some details about the database you plan to integrate with Metabase. Without this information, we won't be able to establish a connection to your database. However, if you prefer to postpone this step, that's perfectly fine. For now, I'm choosing the option **"I'll add my data later"**. Metabase provides a [Sample Database](https://www.metabase.com/glossary/sample_database) that allows you to familiarize yourself with its functionalities.

When you're prepared to establish a connection, you'll require the following details:

- The **hostname** of the server hosting your database
- The **port** used by the database server
- The **database** name
- The **username** associated with the database
- The **password** for the database

If you don't have these details readily available, the individual responsible for managing the database should be able to provide them.

[![db info](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ycwferm0c1e516pvgj9l.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ycwferm0c1e516pvgj9l.gif)

### Connect to Database 🛠️

For those who choose the option **"I'll add my data later"**, skip this part. For those who have their database information ready, you're just a step away from accessing your valuable data. Simply enter your details into the provided form and hit 'Next'.


[![connect db](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/msir35p6a5zpf0gkj46a.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/msir35p6a5zpf0gkj46a.png)

You'll be connected to your database in no time. For additional guidance on database connections, refer to the [Adding and managing databases](https://www.metabase.com/docs/latest/databases/connecting) section.

### Usage Data Preferences 🛠️

Before we proceed, there's a small matter to address regarding your preferences for usage data. Your decision will aid them in enhancing the Metabase experience. As stated in the box:

- Metabase is committed to respecting your privacy and does not collect any information about your data or the results of your queries.
- The data they collect is entirely anonymous.
- You have full control over this feature and can disable data collection at any time via your admin settings.

[![preferences](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z20yclyj2wsqn410rjjp.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z20yclyj2wsqn410rjjp.gif)

### Staying in Touch 🛠️

Congratulations! You're now fully equipped and ready to explore Metabase.

[![staying in touch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j1nn1v60vj9iin6ikxxu.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j1nn1v60vj9iin6ikxxu.gif)

## Metabase Home Page 💻

Here are the few first things you see on the Metabase home page

1. **Home Page Content**: The central part of the image shows sample insights with buttons like "Some insights about Orders," "A summary of People," "A glance at Products," and "A look at Accounts." These are likely the [automatic explorations](https://www.metabase.com/docs/latest/users-guide/14-x-rays) that we can save as [dashboard](https://www.metabase.com/glossary/dashboard).
[![home page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/897jgfaxxgpa1612bix7.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/897jgfaxxgpa1612bix7.png)

2. **Navigation Sidebar**: On the left side, there is a sidebar that seems to list various sections:
   - **Metabase Logo**: Clicking on the Metabase logo will open and close the navigation sidebar. This logo is placed in the upper left corner of the screen.
   - **Home Button**: The icon at the very top of the sidebar, would usually take you back to the home page.
   - **Collections**: Below the Home icon, there is a section for 'Collections' where questions, dashboards, and models are stored. There is a "Your personal collection" section likely for personal drafts and experiments.
   - **Bookmark Section**: Bookmarked items will appear toward the top of the navigation sidebar when there are bookmarked items.
   - **Data Section**: Further down the sidebar, we'd expect to find the Data section, which would list the data sources the application is connected to. In this image, we see "Browse data" which could be part of this section.
   - **Add Your Own Data**: Feature to import or connect to new data sources.
[![sidebar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojkh2zbo8ysrus0ymlgc.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojkh2zbo8ysrus0ymlgc.png)

3. **Settings**: At the upper right, there is a gear icon for settings shows a drop-down menu with five options referring to:
   - **Account settings**: This page allows individual users to manage their personal account details on Metabase. Users can update their first name, last name, email, and language preference. There are also tabs for changing the password, reviewing login history, and setting notification preferences.
   - **Admin settings**: This is the administrative panel for Metabase where system-wide settings are configured. Options include setup, general settings, updates, email configuration, Slack integration, authentication methods, map settings, localization, file uploads, public sharing options, embedding configurations, license information, and caching settings. This page also offers guidance for new admins to help them get started with setup tasks like adding a database, setting up email, inviting team members, and tips for production readiness.
   - [**Help**](https://www.metabase.com/help/): The help section provides support resources for Metabase users. It includes troubleshooting guides, a documentation library for in-depth articles on setup and day-to-day usage, a discussion forum to ask questions and learn from other Metabase users, and learning resources such as tutorials, guides, and articles.
   - **About Metabase**: This option confirms the version of Metabase that is being used, in this case, v0.47.6, along with the build date. It also serves as an acknowledgement of the Metabase trademark and the team behind the product.
[![about metabase](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s538rzwc3cs21awciolp.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s538rzwc3cs21awciolp.png)
   - **Sign out**: This is the option to log out of the current user session in Metabase, ensuring that no unauthorized person can access the data or settings if the user leaves the computer.
[![settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/onpqu6s4p4ggme0tglh3.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/onpqu6s4p4ggme0tglh3.png)

4. **Search Bar**: This search bar is a tool within Metabase that allows users to quickly find dashboards, questions (which are specific queries or reports), collections, and possibly other entities within their Metabase instance.
[![search bar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd1vb4zjgp8bx2h8cf4y.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd1vb4zjgp8bx2h8cf4y.png)

5. **New Button**: This button is used to create new content within Metabase. Here's what each option generally stands for:
   - [**Question**](https://www.metabase.com/glossary/question): This allows you to create a new question, which in Metabase terminology is a query or report. You can use their graphical query builder or write SQL queries to explore your data and get answers.
   - [**SQL Query**](https://www.metabase.com/glossary/sql): Specifically for creating a new question using raw SQL. This is for users who prefer to write their SQL queries manually or who need to perform more complex queries that the graphical interface may not support.
   - [**Dashboard**](https://www.metabase.com/glossary/dashboard): This option is used to create a new dashboard. Dashboards are collections of questions that can be viewed together on a single page, allowing for easy visualization of related data and metrics.
   - [**Collection**](https://www.metabase.com/glossary/collection): Collections in Metabase are like folders, which help organize questions, dashboards, and models. This option lets you create a new collection to organize your Metabase content.
   - [**Model**](https://www.metabase.com/glossary/model): A model is a curated view of a table that simplifies querying for other users. It allows you to define a set of fields from a table, rename them, add descriptions, and set up default aggregations.
[![new button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7o9pysl9iazitbo50kn.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7o9pysl9iazitbo50kn.png)
Here's the simple illustration I made that helps me understand the terms for the first time.
[![illustration of terms](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqysb42s0zpmtj69bos6.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqysb42s0zpmtj69bos6.png)

6. **Customize Button**: This allows users to set a specific dashboard as the Metabase homepage for all users.
[![customize modal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/guftvi95tadvs2ng62c7.png)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/guftvi95tadvs2ng62c7.png)

## Asking Metabase Question 🙋‍♂️

In Metabase, a [question](https://www.metabase.com/glossary/question) constitutes a query, its outcomes, and the presentation of these outcomes, even if it's simply in the form of a [table](https://www.metabase.com/learn/visualization/table). Each question is identified by a title, ID, and a shareable unique URL.

Questions can be manipulated by applying filters and summaries, and these modifications can be saved as separate questions. Additionally, questions can be incorporated into [dashboards](https://www.metabase.com/learn/dashboards). However, let's not get too far ahead— for the forthcoming illustrations, we'll utilize the [Sample Database](https://www.metabase.com/glossary/sample_database) included with Metabase.

To begin, click on `+ New` in the main navigation bar and select `Question`. You have the option to begin crafting a new question using:

- A model
- An unprocessed table
- A previously saved question

For this instance, select `Raw data > Sample database > People` to commence, and Metabase will launch the query builder.

[![new question](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lihjepp1gdyo1l5x654d.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lihjepp1gdyo1l5x654d.gif)

## Filtering Data 🔍

The `People` table is populated with fictitious information. Suppose we are curious about the following:

> What is the count of individuals originating from the states of Washington, Wisconsin, West Virginia, or Wyoming?

To be more specific, we are asking: "_How many entries (or rows) exist within the `People` table where the `State` column contains `WA`, `WI`, `WV`, or `WY`?_"

To determine this, we'll apply a [filter](https://www.metabase.com/glossary/filter) to the dataset focusing on the [field](https://www.metabase.com/glossary/field) of interest, which is `State` in this scenario. Our goal is to tally up the number of rows that meet our criteria.

During the `Filter` phase, we'll press the purple `Add filters to narrow your answer` button and choose `State` as the [column](https://www.metabase.com/glossary/column) to filter by. In the ensuing dropdown, tick the options for `WA`, `WI`, `WV`, and `WY`, and then finalize by clicking `Add filter`.

[![filter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/thx6ngqi0vmzgxvip633.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/thx6ngqi0vmzgxvip633.gif)

## Previewing Results 👓

At any stage, you can use the triangle icon on the right to take a sneak peek at the current results. The gif presented below demonstrates that, following the application of our filter, the individuals hailing from Washington, Wisconsin, West Virginia, or Wyoming are indeed displayed. To exit the preview mode, simply click the `X` located at the top right corner of the preview pane.

[![preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/noh9u2pb3t45wwlcdmtd.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/noh9u2pb3t45wwlcdmtd.gif)

## Summarizing Data 📊

Whenever we use terms like:

- "How many,"
- "What's the total," or
- "What's the average"

We're referring to the process of aggregating our data, essentially speaking of [metrics](https://www.metabase.com/glossary/metric). In this scenario, the metric is the total number (or count) of individuals after filtering by the states of Washington, Wisconsin, West Virginia, or Wyoming. In the `Summarize` step, we'll select the `Pick the metric you want to see` option and choose `Count of rows`.

Upon selecting `Visualize`, Metabase reveals that there are 186 individuals from the specified states. In other words, 186 entries from the `People` table passed through our filter.

[![summary](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vhrzjsn6r7g8yk6lb3w9.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vhrzjsn6r7g8yk6lb3w9.gif)

## Grouping Results 🤝

The total count is insightful, yet it becomes more informative if we discern the timeline of our customers' registrations, especially the monthly registration figures within those states.

To revisit the editor, we can utilize the back button, or select the `Editor` icon situated in the top right (symbolized by a bulleted list). We can also stay on the current page and modify our query by clicking the `Filter` and `Summarize` options.

To categorize our data by month, we'll choose `Summarize`. In the `Summarize sidebar` that appears below our metric selection, there's an assortment of columns available for grouping our data. We'll opt for `Created At` to sort by the registration date, which will segment our counts of individuals in the specified states by each month, aligned with the registration date (`Created_at`). Selecting `Created At` prompts Metabase to display a line chart depicting the registration timeline. The `Created_At` column defaults to a monthly grouping, but we can alter this by clicking on `by month` near `Created At` and choosing another timeframe from the dropdown menu.

Further refinements to our query can be made via the sidebar, or we can return to the full editor view by clicking on the `Editor` button. Below is the enhanced query with our new summarization step:

[![grouping](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8uj8q5njis4amka9d6oe.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8uj8q5njis4amka9d6oe.gif)

## Changing the Visualization 🌆

Metabase offers multiple ways to display the solutions to queries. To switch the display style, simply choose from the alternatives within the `Visualization sidebar` that appears after you click the `Visualization` button located at the page's lower left corner.

Should you prefer to see the data in a tabular format, you have the option to use the `small toggle` situated at the bottom centre of the page. This lets you alternate between the chart view and a data table.

For additional display types, activate the blue `Visualization` button in the lower left corner. For instance, we could represent our query with an `area chart`.

Certain types of visualizations may not suitably convey the answers to some queries, which is why Metabase may exclude such options in the `Other Charts` section. For instance, depicting the aggregate number of individuals from specific states using a `Gauge` or `Progress` bar would not be appropriate.

If you wish to experiment with your query, such as altering the states to other values, simply click on the filter tag located beneath the page title.

To delve deeper into chart options, visit [Visualizing data](https://www.metabase.com/learn/visualization).

[![visual](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pkrjgmmj58t2e23ifrij.gif)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pkrjgmmj58t2e23ifrij.gif)

## References 📚

- [Running Metabase on Docker](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker#open-source-quick-start)
- [Docker Desktop WSL 2 backend on Windows](https://docs.docker.com/desktop/wsl/)
- [Setting up Metabase](https://www.metabase.com/docs/latest/configuring-metabase/setting-up-metabase)
- [Getting started with Metabase](https://www.metabase.com/learn/getting-started/getting-started#the-metabase-home-page)
- [Metabase Data and Business Intelligence Glossary Terms](https://www.metabase.com/glossary/)
- [Docker 4.0: Author's ChatGPT Builder](https://chat.openai.com/g/g-IbnI1P0BO-docker-4-0)

## Connect with Me 👨‍💻

If you've enjoyed this Metabase tutorial and wish to stay updated with more insights, tips, or have any queries, feel free to connect with me. Just click the button below to visit my beacons profile and get in touch. I'm always open to discussions and collaborations!

{% cta https://beacons.ai/ranggakd %} Visit My 👀 Beacons Profile  {% endcta %}