
* added CLI in heading for clearity * added new heading * new change * updated final version for review * fix small line breaks * copy edit, restructuring * Apply suggestions from code review * Apply suggestions from code review * removed internal notes * updateding the docker configuraiton file which have advanced instructions * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * updated persistent stroage section * updated heading typo * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * fixed code identation and minor typos * added yaml file validation check in the troubleshooting section * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md added "also" Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * add more details to apline, cloudwatch and default path sections * Apply suggestions from code review Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * added more detailes about docker ubuntu image, fixed headings, added more clarity to the persistent vs bind stroage * Apply suggestions from code review Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * added more improvements for the examples * Update docs/sources/setup-grafana/installation/docker/index.md * Update docs/sources/setup-grafana/installation/docker/index.md * Update docs/sources/setup-grafana/installation/docker/index.md * Update docs/sources/setup-grafana/configure-docker.md * updates links, edits Troubleshooting section * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Dan Cech <dcech@grafana.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Dan Cech <dcech@grafana.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Dan Cech <dcech@grafana.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Dan Cech <dcech@grafana.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Dan Cech <dcech@grafana.com> * fixes doc-validator issues * adds link to plugin install instructions * added improvement in the AWS cloudwatch example * Update docs/sources/setup-grafana/configure-docker.md * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * Apply suggestions from code review suggestions looks good Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * added dan suggestion for the tags, but skip the longer description part as not really useful for end user * Update docs/sources/setup-grafana/installation/docker/index.md Co-authored-by: Dan Cech <dcech@grafana.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Dan Cech <dcech@grafana.com> * Update docs/sources/setup-grafana/configure-docker.md Co-authored-by: Dan Cech <dcech@grafana.com> * Apply suggestions from code review looks good Co-authored-by: Dan Cech <dcech@grafana.com> * added missing version * fixed identation and small typo * fixed the pwd data folder instruction * fixed persistent volume creating and identation * fixed identation * fixed typo to get debug logs * fixed custom plugin installation section * created docker secret command instructions * fixed missing path * fixed code in docker secret and other minor typos * incorporates feedback, copy edits secrets section * fixed small typo in docker secrets section * remove the additonal info command for secrets * combined custom docker pre-installed plugin section as one * fixed the build link typo * various updates/fixes * another fix * added more clarity to the volume creating command * fixed command for bind mounts * fixed missing comman in the plugin command * fixed small typo * improve and simplifly the steps instructions * fixed validation command * Apply suggestions from code review looks good!! Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * fixed typo in docker secret command explaination * fixed minor stuff * makes prettier --------- Co-authored-by: Chris Moyer <chris.moyer@grafana.com> Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> Co-authored-by: Dan Cech <dcech@grafana.com>
14 KiB
aliases | description | title | weight | |
---|---|---|---|---|
|
Guide for running Grafana using Docker | Run Grafana Docker image | 200 |
Run Grafana Docker image
This topic guides you through installing Grafana via the official Docker images. Specifically, it covers running Grafana via the Docker command line interface (CLI) and docker-compose.
Grafana Docker images come in two editions:
- Grafana Enterprise:
grafana/grafana-enterprise
- Grafana Open Source:
grafana/grafana-oss
Note: The recommended and default edition of Grafana is Grafana Enterprise. It is free and includes all the features of the OSS edition. Additionally, you have the option to upgrade to the full Enterprise feature set, which includes support for Enterprise plugins.
The default images for Grafana are created using the Alpine Linux project and can be found in the Alpine official image. For instructions on configuring a Docker image for Grafana, refer to [Configure a Grafana Docker image]({{< relref "../../configure-docker" >}}).
Run Grafana via Docker CLI
This section shows you how to run Grafana using the Docker CLI.
Note: If you are on a Linux system (for example, Debian or Ubuntu), you might need to add
sudo
before the command or add your user to thedocker
group. For more information, refer to Linux post-installation steps for Docker Engine.
To run the latest stable version of Grafana, run the following command:
docker run -d -p 3000:3000 --name=grafana grafana/grafana-enterprise
Where:
run = run directly from the command line
d
= run in the background
p
= assign the port number, which in this case is 3000
name
= assign a logical name to the container, for example, grafana
grafana/grafana-enterprise
= the image to run in the container
Stop the Grafana container
To stop the Grafana container, run the following command:
# The `docker ps` command shows the processes running in Docker
docker ps
# This will display a list of containers that looks like the following:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cd48d3994968 grafana/grafana-enterprise "/run.sh" 8 seconds ago Up 7 seconds 0.0.0.0:3000->3000/tcp grafana
# To stop the grafana container run the command
# docker stop CONTAINER-ID or use
# docker stop NAME, which is `grafana` as previously defined
docker stop grafana
Save your Grafana data
When you use Docker containers, their data is temporary by default. If you don't specify where to store the information, all the Grafana data will be lost when you stop the Docker container. To avoid losing your data, you can set up persistent storage or bind mounts for your container.
Note: Though both methods are similar, there is a slight difference. If you want your storage to be fully managed by Docker and accessed only through Docker containers and the Docker CLI, you should choose to use persistent storage. However, if you need full control of the storage and want to allow other processes besides Docker to access or modify the storage layer, then bind mounts is the right choice for your environment.
Use persistent storage (recommended)
It is recommended to have persistent storage because, without it, all data will be lost once the container is shut down. Use this method when you want the Docker service to manage the storage volume fully.
To use persistent storage, complete the following steps:
-
Create a Grafana Docker volume
grafana-storage
by running the following commands:# create a persistent volume for your data docker volume create grafana-storage # verify that the volume was created correctly # you should see a json output docker volume inspect grafana-storage
-
Start the Grafana container by running the following command:
# start grafana docker run -d -p 3000:3000 --name=grafana \ --volume grafana-storage:/var/lib/grafana \ grafana/grafana-enterprise
Use bind mounts
If you plan to use folders on your host for the database or configuration when running Grafana in Docker, you must start the container with a user with permission to access and write to the folder you map.
To use bind mounts, run the following command:
# create a folder for your data
mkdir data
# start grafana with your user id and using the data folder
docker run -d -p 3000:3000 --name=grafana \
--user "$(id -u)" \
--volume "$PWD/data:/var/lib/grafana" \
grafana/grafana-enterprise
Use environment variables to configure Grafana
Grafana supports specifying custom configuration settings using [environment variables]({{< relref "../../../setup-grafana/configure-grafana#override-configuration-with-environment-variables" >}}).
# enabling public dashboard feature
docker run -d -p 3000:3000 --name=grafana \
-e "GF_FEATURE_TOGGLES_ENABLE=publicDashboards" \
grafana/grafana-enterprise
Install plugins in the Docker container
You can install plugins in Grafana from the official and community plugins page or by using a custom URL to install a private plugin. These plugins allow you to add new visualization types, data sources, and applications to help you better visualize your data.
Grafana currently supports three types of plugins: panel, data source, and app. For more information on managing plugins, refer to [Plugin Management]({{< relref "../../../administration/plugin-management" >}}).
To install plugins in the Docker container, complete the following steps:
-
Pass the plugins you want to be installed to Docker with the
GF_INSTALL_PLUGINS
environment variable as a comma-separated list.This sends each plugin name to
grafana-cli plugins install ${plugin}
and installs them when Grafana starts.For example:
docker run -d -p 3000:3000 --name=grafana \ -e "GF_INSTALL_PLUGINS=grafana-clock-panel, grafana-simple-json-datasource" \ grafana/grafana-enterprise
-
To specify the version of a plugin, add the version number to the
GF_INSTALL_PLUGINS
environment variable.For example:
docker run -d -p 3000:3000 --name=grafana \ -e "GF_INSTALL_PLUGINS=grafana-clock-panel 1.0.1" \ grafana/grafana-enterprise
Note: If you do not specify a version number, the latest version is used.
-
To install a plugin from a custom URL, use the following convention to specify the URL:
<url to plugin zip>;<plugin install folder name>
.For example:
docker run -d -p 3000:3000 --name=grafana \ -e "GF_INSTALL_PLUGINS=https://github.com/VolkovLabs/custom-plugin.zip;custom-plugin" \ grafana/grafana-enterprise
Example
The following example runs the latest stable version of Grafana, listening on port 3000, with the container named grafana
, persistent storage in the grafana-storage docker volume, the server root URL set, and the official clock panel plugin installed.
# create a persistent volume for your data
docker volume create grafana-storage
# start grafana by using the above persistent storage
# and defining environment variables
docker run -d -p 3000:3000 --name=grafana \
--volume grafana-storage:/var/lib/grafana \
-e "GF_SERVER_ROOT_URL=http://my.grafana.server/" \
-e "GF_INSTALL_PLUGINS=grafana-clock-panel" \
grafana/grafana-enterprise
Run Grafana via Docker Compose
Docker Compose is a software tool that makes it easy to define and share applications that consist of multiple containers. It works by using a YAML file, usually called docker-compose.yaml
, which lists all the services that make up the application. You can start the containers in the correct order with a single command, and with another command, you can shut them down. For more information about the benefits of using Docker Compose and how to use it refer to Use Docker Compose.
Before you begin
To run Grafana via Docker Compose, install the compose tool on your machine. To determine if the compose tool is available, run the following command:
docker compose version
If the compose tool is unavailable, refer to Install Docker Compose.
Run the latest stable version of Grafana
This section shows you how to run Grafana using Docker Compose. The examples in this section use Compose version 3. For more information about compatibility, refer to Compose and Docker compatibility matrix.
Note: If you are on a Linux system (for example, Debian or Ubuntu), you might need to add
sudo
before the command or add your user to thedocker
group. For more information, refer to Linux post-installation steps for Docker Engine.
To run the latest stable version of Grafana using Docker Compose, complete the following steps:
-
Create a
docker-compose.yaml
file.# first go into the directory where you have created this docker-compose.yaml file cd /path/to/docker-compose-folder # now create the docker-compose.yaml file touch docker-compose.yaml
-
Now, add the following code into the
docker-compose.yaml
file.For example:
version: "3.8" services: grafana: image: grafana/grafana-enterprise container_name: grafana restart: unless-stopped ports: - '3000:3000'
-
To run
docker-compose.yaml
, run the following command:# start the grafana container docker compose up -d
Where:
d = detached mode
up = to bring the container up and running
To determine that Grafana is running, open a browser window and type IP_ADDRESS:3000
. The sign in screen should appear.
Stop the Grafana container
To stop the Grafana container, run the following command:
docker compose down
Note: For more information about using Docker Compose commands, refer to docker compose.
Save your Grafana data
When you use Docker containers, their data is temporary by default. If you don't specify where to store the information, all the Grafana data will be lost when you stop the Docker container. To avoid losing your data, you can set up persistent storage or bind mounts for your container.
Use persistent storage (recommended)
It is recommended to have persistent storage because without it, all data will be lost once the container is shut down. Use this method when you want the Docker service to fully manage the storage volume.
Complete the following steps to use persistent storage.
-
Create a
docker-compose.yaml
file# first go into the directory where you have created this docker-compose.yaml file cd /path/to/docker-compose-folder # now create the docker-compose.yaml file touch docker-compose.yaml
-
Add the following code into the
docker-compose.yaml
file.version: '3.8' services: grafana: image: grafana/grafana-enterprise container_name: grafana restart: unless-stopped ports: - '3000:3000' volumes: - grafana_data:/var/lib/grafana volumes: grafana_data: {}
-
Save the file and run the following command:
docker compose up -d
Use bind mounts
If you plan to use folders on your host for the database or configuration when running Grafana in Docker, you must start the container with a user that has the permission to access and write to the folder you map.
To use bind mounts, complete the following steps:
-
Create a
docker-compose.yaml
file# first go into the directory where you have created this docker-compose.yaml file cd /path/to/docker-compose-folder # now create the docker-compose.yaml file touch docker-compose.yaml
-
Create the folder where you will be mounting your data, in this case is
/data
e.g. in your current working directory:mkdir $PWD/data
-
Now, add the following code into the
docker-compose.yaml
file.version: '3.8' services: grafana: image: grafana/grafana-enterprise container_name: grafana restart: unless-stopped # if you are running as root then set it to 0 # else find the right id with the id -u command user: '0' ports: - '3000:3000' # adding the mount volume point which we create earlier volumes: - '$PWD/data:/var/lib/grafana'
-
Save the file and run the following command:
docker compose up -d
Example
The following example runs the latest stable version of Grafana, listening on port 3000, with the container named grafana
, persistent storage in the grafana-storage docker volume, the server root URL set, and the official clock panel plugin installed.
version: "3.8"
services:
grafana:
image: grafana/grafana-enterprise
container_name: grafana
restart: unless-stopped
environment:
- GF_SERVER_ROOT_URL=http://my.grafana.server/
- GF_INSTALL_PLUGINS=grafana-clock-panel
ports:
- '3000:3000'
volumes:
- 'grafana_storage:/var/lib/grafana'
volumes:
grafana_storage: {}
Note: If you want to specify the version of a plugin, add the version number to the
GF_INSTALL_PLUGINS
environment variable. For example:-e "GF_INSTALL_PLUGINS=grafana-clock-panel 1.0.1,grafana-simple-json-datasource 1.3.5"
. If you do not specify a version number, the latest version is used.
Next steps
Refer to the [Getting Started]({{< relref "../../../getting-started/build-first-dashboard" >}}) guide for information about logging in, setting up data sources, and so on.
Configure Docker image
Refer to [Configure a Grafana Docker image]({{< relref "../../configure-docker" >}}) page for details on options for customizing your environment, logging, database, and so on.
Configure Grafana
Refer to the [Configuration]({{< relref "../../configure-grafana" >}}) page for details on options for customizing your environment, logging, database, and so on.