SoFunction
Updated on 2025-03-10

Basic steps to quickly install grafana using Docker

Docker provides a lightweight, easy-to-deploy containerized solution that allows you to run applications in different environments easily. Here are the basic steps to install Grafana in Docker:

Quickly install grafana using Docker

1. Pull the Grafana Docker image:

Execute the following command to pull the Grafana image from Docker Hub:

docker pull grafana/grafana

2. Run the Grafana container:

docker run -d -p 3000:3000 --name=grafana grafana/grafana

Run the Grafana container by executing the following command:

docker run -d -p 3000:3000 --name=grafana grafana/grafana
  • -d: means running the container in the background.
  • -p 3000:3000: Map local port 3000 to port 3000 in the container.
  • --name=grafana: Assign a name to the container, here is "grafana".

3. Access the Grafana Web interface:

Open the browser and accesshttp://localhost:3000. You will be able to configure and use Grafana in the web interface.

4. Log in to Grafana:

The default login username and password are:

  • Username: admin
  • Password: admin

When you log in for the first time, you will be asked to change your password.

This way, you successfully installed and ran Grafana in Docker. Please note that the above commands and port numbers can be adjusted according to your needs. Make sure that the local machine does not occupy port 3000. You can also map container ports to other ports by modifying the port mapping in the Docker command.

If you need to persist data, you can also mount the local directory to the container to save Grafana's configuration files and data. This way, after the container is deleted, the data will not be lost.

How to use Grafana

Grafana is a powerful open source monitoring and data analytics platform that integrates with a variety of data sources and provides flexible visualization and dashboard capabilities. Here are the basic steps for data analysis using Grafana:

Step 1:

  • Log in to Grafana.
  • In the left navigation bar, select Configuration, and then select Data Sources.
  • Click "Add your first data source" to select the type of data source you want to connect to, such as Prometheus, InfluxDB, MySQL, etc.
  • Configure data source connection information, including URL, database, authentication, etc.
  • Click "Save & Test" to verify that the data source connection is successful.

Step 2: Create a dashboard

  • In the left navigation bar, select "+", and then select "Dashboard" -> "Add new panel".
  • Select data source, query and other settings in the Panel.
  • Click “Apply” to save dashboard settings.
  • You can continue to add other charts, tables, etc. through "Add Panel".

Step 3: Visualize the data

  • In the Panel settings, select the chart type, such as line chart, bar chart, pie chart, etc.
  • Configure the data query of the chart and select the metrics and time ranges to be displayed.
  • Adjust the display settings of the chart, including title, label, axis range, etc.

Step 4: Build the dashboard

  • Add multiple panels to the dashboard to showcase different data sources or different metrics.
  • Adjust the layout and style of the dashboard, including row and column settings, background colors, etc.
  • Use "Variables" to create a dynamic dashboard, allowing the user to select different values.

Step 5: Save and share the dashboard

  • Click the Save button in the upper right corner of the dashboard to set the name and folder for the dashboard.
  • With the Share option, generate a shared link or embed code to share the dashboard elsewhere.

Step 6: Alarm settings

  • In Panel settings, configure alert rules to receive notifications when a specific condition is met.
  • In the "Alert" panel, configure notification channels such as email, Slack, and more.

Step 7: Explore the data

  • Use the Explore feature to explore data in your data source and build custom queries.
  • Add new metrics to charts in the dashboard by exploring the panel, viewing and analyzing data.

With the above steps, you can use Grafana for data analysis and create a powerful visual dashboard. Depending on the data sources and needs, you can dig into Grafana’s advanced features and customization options. Grafana's official documentation is also a good resource for learning and use:Grafana Documentation

This is all about this article about using Docker to quickly install grafana. For more related content on installing grafana by Docker, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!