Grafana is a leading open-source tool for visualizing time series data. It’s widely used to visualize data from various sources—such as Prometheus, InfluxDB, and Loki. A fast and flexible way to deploy Grafana is to use Docker, which lets you run it in a containerized environment. This makes it easy and convenient to install the tool without heavy operating system configuration.
In this tutorial, you’ll learn how to run Grafana with Docker. Specifically, you’ll see how to:
Before you begin, make sure your system meets the following requirements:
First, pull the Grafana image from Docker Hub. This image contains everything needed to install and run Grafana in a container. Use:
docker pull grafana/grafana

If you don’t specify a version tag, Docker will automatically pull the latest stable version. If you want a specific version, for example 10.3.1:
docker pull grafana/grafana:10.3.1
You can find all available Grafana tags on Docker Hub.
After running this command:
Once the image is downloaded, you can start a container with a single docker run command. This is the quickest way to run Grafana locally or on a server.
Start command:
docker run -d -p 3000:3000 --name=grafana grafana/grafana
Check that the container is running:
docker ps

In the output, you should see a running container named "grafana".
This approach lets you launch Grafana in seconds - no complex configuration required.
After the container starts, open your browser and navigate to the host’s IP address (the machine running the Docker container) with the Grafana port:
ip-adresas:3000

On the login screen, use the default credentials:
User - admin
Password - admin
After you sign in, Grafana will prompt you to change the default password. It’s recommended to do this immediately, especially if the container is accessible from a public network or the internet.

You’ll then land on the main dashboard, where you can add data sources, create dashboards, and add panels.

By default, all data inside a container is lost when it’s stopped or removed - including plugins, user settings, and dashboards. That’s fine for testing, but not for long-term use.
To persist data, mount a volume so Grafana’s data is stored outside the container.
Create a Docker volume:
docker volume create grafana-storage
This volume will back Grafana’s /var/lib/grafana directory in the container.
1. Check that the volume is created and not in use:
docker volume ls -f dangling=true
2. Stop and remove the existing container:
docker stop grafana docker rm grafana
3. Start a new container with the volume mounted:
docker run -d \ -p 3000:3000 \ --name=grafana \ --volume grafana-storage:/var/lib/grafana \ grafana/grafana
4. Verify the volume is mounted:
docker inspect --format '{{json .Mounts}}' grafana
You can now safely stop, start, or upgrade the container without losing settings. Docker will load files into Grafana’s data directory from the mounted volume, and Grafana will automatically restore your state.
Grafana supports numerous environment variables that let you tailor settings at container startup without editing configuration files. This is especially useful for automation, scripts, and consistent environments.
A few common variables:
GF_SECURITY_ADMIN_PASSWORD - sets the initial admin password.
GF_SERVER_ROOT_URL - defines the root URL; useful when using a reverse proxy.
GF_USERS_ALLOW_SIGN_UP - enables or disables self-service user signup.
GF_INSTALL_PLUGINS - installs plugins automatically at startup (comma-separated list).
Pass environment variables with -e:
docker run -d \ -p 3000:3000 \ --name=grafana \ -e GF_SECURITY_ADMIN_PASSWORD=Password \ -e GF_SERVER_ROOT_URL=http://grafana.example.com \ -e GF_USERS_ALLOW_SIGN_UP=false \ grafana/grafana
In this example:
Creating your own Grafana Docker image lets you:
1. Create a Dockerfile:
FROM grafana/grafana:latest # Install one or more plugins RUN grafana-cli plugins install grafana-clock-panel # Optional: add your configuration # COPY custom.ini /etc/grafana/grafana.ini2. Build the image:
docker build -t my-grafana-custom .
3. Run the custom image:
docker run -d \ -p 3000:3000 \ --name=grafana-custom \ my-grafana-custom
This container behaves like a standard Grafana instance, but with your plugins and changes. You can still mount volumes and pass environment variables. Custom images are great for teams, CI/CD pipelines, and repeatable deployments, giving you full control with minimal setup.
Use a custom image if you:
Managing containers with docker run works for a single instance. But as your environment grows, or if you want a cleaner, repeatable deployment - use Docker Compose. It lets you describe the entire configuration in a single YAML file and start everything with one command.
Create a docker-compose.yml file:
version: '3.8'
services:
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=Password
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- grafana-storage:/var/lib/grafana
restart: unless-stopped
volumes:
grafana-storage:docker-compose up -dTo stop the container:
docker-compose down
This configuration:
How to create a user account on Ubuntu serverUbuntu typically comes with a single main user who has root (administrative) privileges. In many cases, you’ll...
How to install LAMP server (Linux, Apache, MySQL, PHP)LAMP ("Linux-Apache-MySQL-PHP") is a popular open-source stack for hosting dynamic websites. Because it is free, highly adaptable,...