You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Docker容器为Grafana安装mongodb-grafana插件?

Installing MongoDB Grafana Plugin in Docker

Since you already know how to set up this plugin on bare-metal Linux, getting it working in a Docker container just requires a couple of container-specific adjustments. Let's cover two reliable methods: building a custom Grafana image (great for production), and mounting a local plugin directory (perfect for quick testing).

This approach bakes the plugin directly into your Grafana image, so you don't have to fuss with mounting directories every time you spin up a container.

  1. Create a Dockerfile in a new directory:
# Start with the official Grafana base image
FROM grafana/grafana:latest

# Install the MongoDB datasource plugin using Grafana's CLI tool
RUN grafana-cli plugins install jamesosgood-mongodb-datasource
  1. Build your custom Grafana image with the plugin included:
docker build -t my-grafana-with-mongodb .
  1. Run the container using your newly built image:
docker run -d -p 3000:3000 my-grafana-with-mongodb

Method 2: Mount a Local Plugin Directory (Quick Testing)

If you don't want to build a new image, you can install the plugin to a local directory and mount it into the Grafana container.

  1. Create a local directory to store Grafana plugins:
mkdir -p ./grafana-plugins
  1. Use a temporary Grafana container to install the plugin into your local directory:
docker run --rm -v ./grafana-plugins:/var/lib/grafana/plugins grafana/grafana:latest grafana-cli plugins install jamesosgood-mongodb-datasource
  1. Fix directory permissions (Grafana runs as UID 472 inside the container, so we need to match that locally):
chown -R 472:472 ./grafana-plugins
  1. Start your persistent Grafana container with the plugin directory mounted:
docker run -d -p 3000:3000 -v ./grafana-plugins:/var/lib/grafana/plugins grafana/grafana:latest

Verify the Installation

Once your container is up and running, log into Grafana (default credentials: admin/admin), head to Configuration > Data Sources, and you should see "MongoDB" listed as an available datasource. You're all set to start building dashboards for your MongoDB data!

内容的提问来源于stack exchange,提问作者Ryan Wegmeier

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:39:09