Deploy Grafana Container with Docker Compose


Grafana is an open-source analytics and visualization platform used to monitor and analyze data from various sources. It provides a flexible and customizable interface for creating and displaying real-time dashboards, graphs, and charts. Grafana supports a wide range of data sources, including databases, time-series databases like Prometheus and InfluxDB, cloud monitoring services, and more.

Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to define an entire application stack, including services, networks, and volumes, in a single file called docker-compose.yml. With a single command, you can then spin up your entire application stack, simplifying the process of managing and deploying multi-container Docker applications.


  • Up and running ubuntu 22.04 LTS machine.
  • Basic knowledge in linux commands.
  • Internet connectivity.
  • Docker and docker compose should installed on your machine.

To install Docker and docker compose on ubuntu 22.04 LTS, We can use the given link.

In this post, We will deploy Grafana container using Docker Compose on Ubuntu 22.04 LTS Debian machine.

Step 1: Creating docker-compose.yml

To deploy Grafana using Docker Compose, you can create a docker-compose.yml file with the necessary configuration. Here’s a basic example to help you get started:

To create a separate directory for Grafana’s docker-compose.yml file.

sudo mkdir grafana && cd grafana

To create a docker-compose.yml

sudo nano docker-compose.yml

Copy and paste the followings configuration.

version: '3'

    image: grafana/grafana
    container_name: grafana
      - "3000:3000"
      - grafana_data:/var/lib/grafana


This Docker Compose file:

  • Uses the official Grafana image.
  • Maps port 3000 to the host machine.
  • Mounts a volume named grafana_data to persist Grafana data.
  • Sets the Grafana admin password to “admin” using the GF_SECURITY_ADMIN_PASSWORD environment variable.

Save the docker-compose.yml file.

Step 2: Deploy Grafana Container

In the directory where your docker-compose.yml file is located, run the following command to start the Grafana container:

sudo docker-compose up -d

The -d flag runs the containers in the background, It will take few sec or mins to pull the image and deploy the Grafana.

Step 3: Validate the Container

To check the running containers launched by Docker Compose, you can use the following command:

sudo docker-compose ps

This command provides a summary of the status of each service defined in your docker-compose.yml file. It shows information such as the service name, container ID, status, ports, and names.

Step 4: Logging

Some time we need to also check the real time logs, So we can use the given commands.

sudo docker-compose logs -f grafana

Step 5: Accessing Grafana GUI

Access Grafana by opening your web browser and navigating to http://localhost:3000 or http://IPaddress:3000.

Grafana default Credentials.

Password admin

Log in with the username “admin” and the password “admin” (as specified in the docker-compose.yml file).

Once logged in, you can configure Grafana to connect to data sources and create dashboards.

Step 6: Destroying Grafana Container

We need to execute the given command to destroy the Grafana’s docker container under docker compose.

sudo docker compose down 


We have successfully deployed Grafana analytics tool docker’s container using docker compose on ubuntu 22.04 LTS Debian machine, If you still have questions, please post them in the comments section below.


Deploy Grafana Container with Docker Compose

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top