{"id":129814,"date":"2025-06-17T13:13:02","date_gmt":"2025-06-17T13:13:02","guid":{"rendered":"\/tutorials\/?p=129814"},"modified":"2026-03-09T19:16:28","modified_gmt":"2026-03-09T19:16:28","slug":"how-to-run-grafana-docker-image","status":"publish","type":"post","link":"\/ng\/tutorials\/how-to-run-grafana-docker-image","title":{"rendered":"How to run a Grafana Docker image?"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p><strong>Grafana<\/strong> is a leading open-source tool for visualizing time-series data, offering intuitive dashboards and monitoring capabilities. It is widely used to visualize data from various sources like <strong>Prometheus<\/strong>, <strong>InfluxDB<\/strong>, and <strong>Loki<\/strong>. Running Grafana efficiently is crucial for effective data analysis, but setting it up manually can be complex.<\/p><p>The fastest and most flexible way to deploy Grafana is through <strong>Docker<\/strong>, which allows you to run Grafana in a containerized environment. This eliminates the need for intricate system configurations or dealing with dependencies.<\/p><p>In this guide, we&rsquo;ll walk you through the process of running Grafana in Docker. Specifically, you&rsquo;ll learn how to:<\/p><ol class=\"wp-block-list\">\n<li><strong>Pull and run the Grafana Docker image<\/strong> with a simple command.<\/li>\n\n\n\n<li><strong>Expose Grafana ports<\/strong> to access the web UI.<\/li>\n\n\n\n<li><strong>Persist your Grafana settings and dashboards<\/strong> across container restarts.<\/li>\n\n\n\n<li><strong>Configure Grafana<\/strong> using environment variables or a Dockerfile.<\/li>\n\n\n\n<li><strong>Simplify Grafana deployment<\/strong> using Docker Compose for multi-container orchestration.<\/li>\n<\/ol><p>By following these steps, you&rsquo;ll have Grafana running in a Docker container, ready for monitoring and visualization. This article covers everything you need, from the basics to advanced configuration options.<\/p><p>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-prerequisites\"><strong>Prerequisites<\/strong><\/h2><p>Before you start, make sure your system meets the following requirements:<\/p><ul class=\"wp-block-list\">\n<li><strong>Docker installed<\/strong>: You need <a href=\"\/ng\/tutorials\/how-to-install-docker-on-ubuntu\">Docker Engine installed<\/a> and running on your system. If you want to get started quickly, Hostinger offers a one-click Docker installation template with our <a href=\"\/ng\/vps-hosting\">VPS hosting plans<\/a>.<\/li>\n\n\n\n<li><strong>Command-line familiarity<\/strong>: You&rsquo;ll need to be comfortable using a terminal to run <a href=\"\/ng\/tutorials\/docker-cheat-sheet\">Docker commands<\/a>. Hostinger offers an easy-to-use <strong>browser console<\/strong>, which enables you to run commands directly in the browser window.<\/li>\n\n\n\n<li><strong>Sudo access<\/strong>: On Linux, you must prefix Docker commands with sudo or <a href=\"\/ng\/tutorials\/how-to-fix-docker-permission-denied-error#2_Add_user_to_the_Docker_group\">add your user to the docker group<\/a>.<\/li>\n<\/ul><p>Once these are in place, you&rsquo;ll be ready to begin.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ng\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/public\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-pulling-the-grafana-docker-image\"><strong>Pulling the Grafana Docker image<\/strong><\/h2><p>To get started, you need to download the Grafana image from Docker Hub. This image contains everything required to <a href=\"\/ng\/tutorials\/how-to-install-grafana\">install Grafana<\/a> and run it in a containerized environment.<\/p><p>Here&rsquo;s the basic command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker pull grafana\/grafana<\/pre><p>Docker automatically pulls the most recent stable release if you don&rsquo;t specify a version tag. If you do want a specific version, let&rsquo;s say <strong>10.3.1<\/strong>, your command should look like this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker pull grafana\/grafana:10.3.1<\/pre><p>All available Grafana version tags can be found on <a href=\"https:\/\/hub.docker.com\/r\/grafana\/grafana\/tags\">Docker Hub<\/a>.<\/p><p>Running this will:<\/p><ul class=\"wp-block-list\">\n<li>Download the official Grafana Docker image and store it locally on your machine.<\/li>\n\n\n\n<li>Ensure that Docker can spin up containers using this image by adding the necessary dependencies.<\/li>\n<\/ul><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e405c0c\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"664\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/pull-grafana.png\/public\" alt=\"Terminal window displaying command docker pull grafana executed and its results\" class=\"wp-image-129818\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/pull-grafana.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/pull-grafana.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/pull-grafana.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/pull-grafana.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/pull-grafana.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>You only need to run <strong>docker pull<\/strong> once, unless you want to refresh your image to get the latest updates.<\/p><h2 class=\"wp-block-heading\" id=\"h-running-the-grafana-container\"><strong>Running the Grafana container<\/strong><\/h2><p>Once the Grafana image is pulled, you can <a href=\"\/ng\/tutorials\/docker-start-a-container\/\">start a Docker container<\/a> with a single <strong>docker run<\/strong> command. This is the fastest way to run Grafana locally or on a server.<\/p><p>Here&rsquo;s a basic example:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run -d -p 3000:3000 --name=grafana grafana\/grafana<\/pre><p>Let&rsquo;s break down what this does:<\/p><ul class=\"wp-block-list\">\n<li><strong>docker run<\/strong>: Tells Docker to create and start a new container.<\/li>\n\n\n\n<li><strong>-d<\/strong>: Runs the Docker container in detached mode, so it runs in the background.<\/li>\n\n\n\n<li><strong>-p 3000:3000<\/strong>: Maps port 3000 on your host to port 3000 in the Docker container, the default port Grafana uses.<\/li>\n\n\n\n<li><strong>&ndash;name=grafana<\/strong>: Gives your Docker container a recognizable name (<strong>grafana<\/strong>), so you can refer to it easily in future commands.<\/li>\n\n\n\n<li><strong>grafana\/grafana<\/strong>: Specifies the Docker image to use.<\/li>\n<\/ul><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e406606\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"114\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/run-grafana-default.png\/public\" alt=\"Terminal displaying docker run grafana command executed\" class=\"wp-image-129820\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/run-grafana-default.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/run-grafana-default.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/run-grafana-default.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/run-grafana-default.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/run-grafana-default.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Once the container starts, Grafana will be set up. You can confirm the Grafana Docker container is up by running:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker ps<\/pre><p>In the results, you will see a running Docker container named <strong>grafana<\/strong>, similar to this:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e406ef4\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"71\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-running.png\/public\" alt=\"Terminal window with executed docker ps command and Names grafana highlighted in the results\" class=\"wp-image-129821\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-running.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-running.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-running.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-running.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-running.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>This method gets you up and running with Grafana in seconds &ndash; no config files, no manual setup. It&rsquo;s great for quick testing or local development.<\/p><h2 class=\"wp-block-heading\" id=\"h-accessing-the-grafana-dashboard\"><strong>Accessing the Grafana dashboard<\/strong><\/h2><p>Once your Grafana container is running, you can access its web interface directly from your browser. Open the browser of your choice and navigate to <strong>http:\/\/localhost:3000<\/strong>.<\/p><p><div><p class=\"important\"><strong>Important!<\/strong> If you&rsquo;re running the Docker container on a remote server, replace <strong>localhost<\/strong> with the server&rsquo;s IP address or domain name.<\/p><\/div>\n\n\n\n<\/p><p>Once connected, you&rsquo;ll see a login screen:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e407928\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"920\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-login.png\/public\" alt=\"Image displaying default Grafana login screen\" class=\"wp-image-129822\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-login.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-login.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-login.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-login.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-login.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Grafana&rsquo;s default login credentials are:<\/p><ul class=\"wp-block-list\">\n<li><strong>Username<\/strong> &ndash; admin<\/li>\n\n\n\n<li><strong>Password<\/strong> &ndash; admin<\/li>\n<\/ul><p>After logging in, Grafana will prompt you to change the default password:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e40820e\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"1171\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-change-password.png\/public\" alt=\"Grafana change password dialog\" class=\"wp-image-129823\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-change-password.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-change-password.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-change-password.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-change-password.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-change-password.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>It&rsquo;s strongly recommended that you do this right away, especially if the Docker container is exposed on a public network or the internet.<\/p><p>Once logged in, you&rsquo;ll land on the main dashboard interface, which will look something like this:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e408987\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"734\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-homepage.png\/public\" alt=\"Default Grafana landing page\" class=\"wp-image-129824\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-homepage.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-homepage.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-homepage.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-homepage.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/grafana-homepage.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Here you can add data sources, create panels, and build custom dashboards.<\/p><h2 class=\"wp-block-heading\" id=\"h-persisting-grafana-data\"><strong>Persisting Grafana data<\/strong><\/h2><p>By default, any data you create inside a Docker container will be lost when the container is stopped or removed. This includes plugins, user settings, and Grafana dashboards. While this is fine for quick testing, it&rsquo;s not viable for long-term use.<\/p><p>To prevent data loss, you need to mount a persistent volume so that Grafana&rsquo;s data is stored outside the Docker container:<\/p><ol class=\"wp-block-list\">\n<li>Create a named Grafana Docker volume with the <strong>docker volume<\/strong> command:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker volume create grafana-storage<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e4091c8\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"98\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-create.png\/public\" alt=\"Terminal window with docker volume create command executed and volume name returned as result\" class=\"wp-image-129825\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-create.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-create.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-create.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-create.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-create.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>This volume will store Grafana&rsquo;s data directory <strong>\/var\/lib\/grafana<\/strong> inside the Docker container.<br><br>You can run <strong>docker volume ls -f dangling=true<\/strong> to confirm the volume has been created and is not in use by any Docker container:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e4098bf\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"162\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-not-in-use.png\/public\" alt=\"Terminal window showing grafana-storage volume listed\" class=\"wp-image-129826\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-not-in-use.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-not-in-use.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-not-in-use.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-not-in-use.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-not-in-use.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"2\" class=\"wp-block-list\">\n<li>Stop and remove the currently running Docker container with these commands:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker stop grafana\ndocker rm grafana<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Run a new Grafana Docker container while mounting the volume:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run -d \n  -p 3000:3000 \n  --name=grafana \n  --volume grafana-storage:\/var\/lib\/grafana \n  grafana\/grafana<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Confirm the volume is mounted with <strong>docker inspect<\/strong>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker inspect --format '{{json .Mounts}}' grafana<\/pre><p>This will return a list of mounted volumes, where you will see the volume you created listed now:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e197e40a0b4\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"83\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-mounted.png\/public\" alt=\"Terminal window showing results of filtered docker inspect command for grafana container - Name grafana-storage highlighted\" class=\"wp-image-129827\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-mounted.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-mounted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-mounted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-mounted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/volume-mounted.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>You can now safely stop, restart, or upgrade the Docker container without losing your setup. Docker will load files from the mounted volume to Grafana&rsquo;s data directory, and Grafana will load your saved state automatically.<\/p><h2 class=\"wp-block-heading\" id=\"h-configuring-grafana-with-environment-variables\"><strong>Configuring Grafana with environment variables<\/strong><\/h2><p>Grafana supports many environment variables that let you customize settings during Docker container startup without editing config files. This is especially useful for automation, scripting, or running Grafana in a consistent state across environments.<\/p><p>Here are a few common environment variables you might want to set:<\/p><ul class=\"wp-block-list\">\n<li><strong>GF_SECURITY_ADMIN_PASSWORD<\/strong> &ndash; Sets the initial admin password.<\/li>\n\n\n\n<li><strong>GF_SERVER_ROOT_URL<\/strong> &ndash; Defines the root URL, useful when Grafana is behind a reverse proxy.<\/li>\n\n\n\n<li><strong>GF_USERS_ALLOW_SIGN_UP<\/strong> &ndash; Enables or disables user sign-ups.<\/li>\n\n\n\n<li><strong>GF_INSTALL_PLUGINS<\/strong> &ndash; Auto-installs plugins at startup, defined in a comma-separated list.<\/li>\n<\/ul><p>To pass environment variables, use the <strong>-e<\/strong> flag in your <strong>docker run<\/strong> command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run -d \n\n&nbsp;&nbsp;-p 3000:3000 \n\n&nbsp;&nbsp;--name=grafana \n\n&nbsp;&nbsp;-e GF_SECURITY_ADMIN_PASSWORD=SuperSecurePass \n\n&nbsp;&nbsp;-e GF_SERVER_ROOT_URL=http:\/\/mygrafana.example.com \n\n&nbsp;&nbsp;-e GF_USERS_ALLOW_SIGN_UP=false \n\n&nbsp;&nbsp;grafana\/grafana<\/pre><p>In this example, we:<\/p><ul class=\"wp-block-list\">\n<li>Change the default admin password from admin to <strong>SuperSecurePass<\/strong>.<\/li>\n\n\n\n<li>Tell Grafana its root URL is <strong>http:\/\/mygrafana.example.com<\/strong> when running behind a proxy.<\/li>\n\n\n\n<li>Disable the sign-up option for new users by setting <strong>GF_USERS_ALLOW_SIGN_UP<\/strong> to <strong>false<\/strong>.<\/li>\n<\/ul><p>You can combine this with volume mounting for a fully customized and persistent setup.<\/p><p>Environment variables are applied each time the Docker container starts, making them ideal for version-controlled deployments or Docker Compose configurations.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-build-a-custom-grafana-docker-image\"><strong>How to build a custom Grafana Docker image<\/strong><\/h2><p>You may want more than just the base Grafana setup in some cases. For example, you might want to:<\/p><ul class=\"wp-block-list\">\n<li>Pre-install specific plugins<\/li>\n\n\n\n<li>Include custom configuration files<\/li>\n\n\n\n<li>Apply branding or themes<\/li>\n\n\n\n<li>Bake in environment-specific settings<\/li>\n<\/ul><p>Rather than configuring all of this every time a container runs, you can build a custom Grafana Docker image with a custom <strong>Dockerfile<\/strong> that includes everything out of the box. Here are step-by-step instructions:<\/p><ol class=\"wp-block-list\">\n<li>Create a <strong>Dockerfile<\/strong> &ndash; it&rsquo;s a simple text file with instructions for Docker. Here&rsquo;s an example:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">FROM grafana\/grafana:latest\n\n# Install one or more plugins\nRUN grafana-cli plugins install grafana-clock-panel\n\n# Optional: copy in custom config files\n# COPY custom.ini \/etc\/grafana\/grafana.ini<\/pre><p>In this example, we start from a default Grafana Docker image and install the Grafana Clock Panel plugin on top. Save it as <strong>Dockerfile<\/strong> in a directory of your choice.<\/p><ol start=\"2\" class=\"wp-block-list\">\n<li>Build the Docker image with the <strong>docker build<\/strong> command:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker build -t my-grafana-custom .<\/pre><p>This creates a new image tagged <strong>my-grafana-custom<\/strong>.<\/p><p><div><p class=\"important\"><strong>Important!<\/strong> Replace the . symbol at the end with the path to your <strong>Dockerfile<\/strong> if you&rsquo;re running the command from a different directory.<\/p><\/div>\n\n\n\n<\/p><ol start=\"3\" class=\"wp-block-list\">\n<li>Run the custom image to start a Docker container. Use the <strong>docker run<\/strong> command:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run -d \n  -p 3000:3000 \n  --name=grafana-custom \n  my-grafana-custom<\/pre><p>This container behaves like any Grafana instance but comes with your plugins and customizations already installed. You can still attach volumes and pass environment variables as needed.<\/p><p>Custom images are great for teams, CI\/CD pipelines, and repeatable deployments, giving you full control over your Grafana instance with minimal setup. Use a custom image if:<\/p><ul class=\"wp-block-list\">\n<li>You deploy Grafana frequently and want a consistent, ready-to-go setup<\/li>\n\n\n\n<li>You&rsquo;re automating infrastructure and need a plug-and-play solution<\/li>\n\n\n\n<li>You want to include plugins or configs without manual intervention<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-running-grafana-with-docker-compose\"><strong>Running Grafana with Docker Compose<\/strong><\/h2><p>Managing containers with <strong>docker run<\/strong> works fine for single instances. However, as your setup grows, or if you want a cleaner, more repeatable deployment, <strong>Docker Compose<\/strong> is the way to go. It lets you define your entire container configuration in a single YAML file and spin everything up with one command.<\/p><h3 class=\"wp-block-heading\" id=\"h-why-use-docker-compose\"><strong>Why use Docker Compose?<\/strong><\/h3><ul class=\"wp-block-list\">\n<li>It simplifies multi-container setups like Grafana and Prometheus.<\/li>\n\n\n\n<li>It keeps configuration in version control.<\/li>\n\n\n\n<li>It makes environment replication easy across local and remote machines.<\/li>\n\n\n\n<li>It requires less typing, especially when using volumes, networks, and environment variables.<\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-simplifying-setup-with-docker-compose\"><strong>Simplifying setup with Docker Compose<\/strong><\/h3><p>Let&rsquo;s set up Grafana using Docker Compose:<\/p><ol class=\"wp-block-list\">\n<li>Create a <strong>docker-compose.yml<\/strong> file. Here is an example file:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">version: '3.8'\n#start a services block\nservices:\n  #start grafana block\n  grafana:\n    #define the image to use\n    image: grafana\/grafana:latest\n    #name the Docker container\n    container_name: grafana\n    #map ports\n    ports:\n      - \"3000:3000\"\n    #define environment variables\n    environment:\n      - GF_SECURITY_ADMIN_PASSWORD=StrongPassword123\n      - GF_USERS_ALLOW_SIGN_UP=false\n    #mount a volume\n    volumes:\n      - grafana-storage:\/var\/lib\/grafana\n    restart: unless-stopped\n\nvolumes:\n  grafana-storage:<\/pre><p>Save it in the directory from which you&rsquo;ll be running your container.<\/p><ol start=\"2\" class=\"wp-block-list\">\n<li>Run the Grafana container with the <strong>docker-compose up<\/strong> command:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker-compose up -d<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>And if you need to stop the container:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker-compose down<\/pre><p>In this example, we:<\/p><ul class=\"wp-block-list\">\n<li>Pull the Grafana image if it&rsquo;s not already local.<\/li>\n\n\n\n<li>Create and run the Docker container in detached mode with <strong>-d<\/strong> flag.<\/li>\n\n\n\n<li>Automatically recreate the container on reboot, thanks to <strong>restart: unless-stopped<\/strong>.<\/li>\n\n\n\n<li>Store data persistently using the named volume <strong>grafana-storage<\/strong>.<\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-multi-tool-setup-with-docker-compose\"><strong>Multi-tool setup with Docker Compose<\/strong><\/h3><p>Docker Compose really shines when deploying multiple tools at once. Let&rsquo;s review an example setup with:<\/p><ul class=\"wp-block-list\">\n<li><strong>Prometheus<\/strong> &ndash; To collect metrics from configured targets.<\/li>\n\n\n\n<li><strong>Grafana<\/strong> &ndash; To visualize those metrics using dashboards.<\/li>\n\n\n\n<li>A shared network and persistent storage for both services.<\/li>\n<\/ul><ol class=\"wp-block-list\">\n<li>Create a <strong>prometheus.yml<\/strong> file for Prometheus configuration:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">global:\n  scrape_interval: 15s\n\nscrape_configs:\n  - job_name: 'prometheus'\n    static_configs:\n      - targets: ['localhost:9090']\n<\/pre><p>You can add other exporters later (like <strong>node_exporter<\/strong> or <strong>cAdvisor<\/strong>) by extending this config.<\/p><ol start=\"2\" class=\"wp-block-list\">\n<li>Create a <strong>docker-compose.yml<\/strong> file for both tools:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">version: '3.8'\n\nservices:\n  prometheus:\n    image: prom\/prometheus:latest\n    container_name: prometheus\n    volumes:\n      - prometheus-data:\/prometheus\n      - .\/prometheus.yml:\/etc\/prometheus\/prometheus.yml\n    ports:\n      - \"9090:9090\"\n    restart: unless-stopped\n\n  grafana:\n    image: grafana\/grafana:latest\n    container_name: grafana\n    environment:\n      - GF_SECURITY_ADMIN_PASSWORD=admin123\n    ports:\n      - \"3000:3000\"\n    volumes:\n      - grafana-data:\/var\/lib\/grafana\n    restart: unless-stopped\n    depends_on:\n      - prometheus\n\nvolumes:\n  prometheus-data:\n  grafana-data:\n<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Start both containers with Docker Compose:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker-compose up -d<\/pre><p>Make sure you execute this command from the same directory where you saved <strong>docker-compose.yml <\/strong>and <strong>prometheus.yml <\/strong>files.<\/p><p>You now have Grafana accessible at <strong>http:\/\/localhost:3000<\/strong> and Prometheus at <strong>http:\/\/localhost:9090<\/strong>. The only thing left to do is to add Prometheus as a data source on the Grafana dashboard, and your metric collection will be ready to go!<\/p><p>Using Docker Compose makes your setup more maintainable and production-friendly, especially when you&rsquo;re ready to expand beyond just Grafana.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\"><strong>Conclusion<\/strong><\/h2><p>Running Grafana in Docker is one of the fastest and most flexible ways to get up and running with powerful dashboards and monitoring.<\/p><p>Here are the key takeaways:<\/p><ul class=\"wp-block-list\">\n<li>You can start Grafana instantly using a simple <strong>docker run<\/strong> command.<\/li>\n\n\n\n<li>Persisting data with volumes ensures your dashboards, settings, and plugins aren&rsquo;t lost between sessions.<\/li>\n\n\n\n<li>Environment variables let you preconfigure Grafana on launch &ndash; great for automation and consistency.<\/li>\n\n\n\n<li>A custom Docker image allows you to preinstall plugins or embed default settings.<\/li>\n\n\n\n<li>Docker Compose simplifies multi-container setups and makes your deployments repeatable and easy to manage.<\/li>\n<\/ul><p>With just a few commands, you can go from zero to a fully functioning Grafana instance. Whether you&rsquo;re building a monitoring stack, testing data sources, or sharing dashboards with your team, Docker gives you the speed and flexibility to move fast without cutting corners.<\/p><p>Now that you&rsquo;ve got the fundamentals down, try connecting Grafana to a data source like Prometheus or InfluxDB, explore community plugins, or even automate the whole thing as part of your CI\/CD pipeline.<\/p><h2 class=\"wp-block-heading\" id=\"h-running-a-grafana-docker-image-faq\"><strong>Running a Grafana Docker image<\/strong><strong> FAQ<\/strong><\/h2><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1750165071011\"><h3 class=\"schema-faq-question\"><strong>What is a Grafana Docker image?<\/strong><\/h3> <p class=\"schema-faq-answer\">Grafana Docker image is a pre-packaged version of Grafana bundled with all necessary dependencies. It&rsquo;s designed to run inside a Docker container, and lets you deploy Grafana quickly and consistently across environments without manually installing or configuring software on your host machine.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1750165082044\"><h3 class=\"schema-faq-question\"><strong>How do I pull the Grafana Docker image?<\/strong><\/h3> <p class=\"schema-faq-answer\">To pull the Grafana image from Docker Hub, run:<br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\"><strong>docker pull grafana\/grafana<\/strong><br><\/code>This command downloads the latest stable version of Grafana to your system so it&rsquo;s ready to use. You can also specify a version tag like <strong>grafana\/grafana:10.3.1<\/strong> to pull a specific release.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1750165102798\"><h3 class=\"schema-faq-question\"><strong>What are the basic commands to run Grafana in Docker?<\/strong><\/h3> <p class=\"schema-faq-answer\">The simplest way to run Grafana in Docker is using the <strong>docker run<\/strong> command:<br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\"><strong>docker run -d -p 3000:3000 --name=grafana grafana\/grafana<\/strong><br><\/code>This starts Grafana in detached mode, maps port 3000, and makes the dashboard accessible at <strong>http:\/\/localhost:3000<\/strong>. Use <strong>docker stop grafana<\/strong> to stop the Docker container.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Grafana is a leading open-source tool for visualizing time-series data, offering intuitive dashboards and monitoring capabilities. It is widely used to visualize data from various sources like Prometheus, InfluxDB, and Loki. Running Grafana efficiently is crucial for effective data analysis, but setting it up manually can be complex. The fastest and most flexible way to [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/how-to-run-grafana-docker-image\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":471,"featured_media":143219,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to run the Grafana Docker Image","rank_math_description":"Learn how to run the Grafana Docker image, configure it, and keep your data safe using volumes and Docker Compose","rank_math_focus_keyword":"grafana docker image","footnotes":""},"categories":[22644],"tags":[],"class_list":["post-129814","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-run-grafana-docker-image","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-run-grafana-docker-image","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-run-grafana-docker-image","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-run-grafana-docker-image","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-run-grafana-docker-image","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-run-grafana-docker-image","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-run-grafana-docker-image","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-run-grafana-docker-image","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/129814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/471"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=129814"}],"version-history":[{"count":6,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/129814\/revisions"}],"predecessor-version":[{"id":143218,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/129814\/revisions\/143218"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media\/143219"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=129814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=129814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=129814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}