DEV Community

Cover image for Understanding the Process of Running Metabase on Docker for the First Time ๐Ÿ“Š๐Ÿ‹
Retiago Drago
Retiago Drago

Posted on

Understanding the Process of Running Metabase on Docker for the First Time ๐Ÿ“Š๐Ÿ‹

Outlines

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.

  1. Get the latest Docker image:
    docker pull

    docker pull metabase/metabase:latest
    

    ๐Ÿ”Ž 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.

  2. Start the Metabase container anywhere and go to http://localhost:3000:
    docker run

    docker run -d -p 3000:3000 --name metabase metabase/metabase
    

    ๐Ÿ”Ž 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.

  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:

    docker stop metabase && docker rm metabase
    

    ๐Ÿ”Ž 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.

  4. To start the Metabase again without removing them beforehand:

    docker start metabase
    

    ๐Ÿ”Ž 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.

Setting Up Metabase ๐Ÿ› ๏ธ

setup metabase

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

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 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

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

You'll be connected to your database in no time. For additional guidance on database connections, refer to the Adding and managing databases 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

Staying in Touch ๐Ÿ› ๏ธ

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

staying in touch

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 that we can save as dashboard.
    home page

  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
  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: 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
    • 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
  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

  5. New Button: This button is used to create new content within Metabase. Here's what each option generally stands for:

    • 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: 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: 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: 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: 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 Here's the simple illustration I made that helps me understand the terms for the first time. illustration of terms
  6. Customize Button: This allows users to set a specific dashboard as the Metabase homepage for all users.
    customize modal

Asking Metabase Question ๐Ÿ™‹โ€โ™‚๏ธ

In Metabase, a question constitutes a query, its outcomes, and the presentation of these outcomes, even if it's simply in the form of a 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. However, let's not get too far aheadโ€” for the forthcoming illustrations, we'll utilize the 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

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 to the dataset focusing on the 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 to filter by. In the ensuing dropdown, tick the options for WA, WI, WV, and WY, and then finalize by clicking Add filter.

filter

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

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. 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

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

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.

visual

References ๐Ÿ“š

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!

Visit My ๐Ÿ‘€ Beacons Profile

Top comments (0)