Running Grafana in a Docker Container with Docker Compose
Grafana (https://grafana.com) is a powerful open-source platform for data visualization and analytics. In this guide, I will show you how to run Grafana in a Docker container using Docker Compose.
Prerequisites
Before we begin, ensure you have Docker installed on your system. If not, you can install Docker from the official Docker website.
Create a Docker Compose File
Create a new file named docker-compose.yml
in your desired directory and add the following content:
version: '3'
services:
grafana:
image: grafana/grafana-oss:11.4.0
container_name: grafana
restart: unless-stopped
user: '0' # Use '0' for root, or find your user ID with 'id -u'
ports:
- '3000:3000'
volumes:
- '$PWD/data:/var/lib/grafana'
Start Grafana
- Open your terminal
- Navigate to the directory containing your
docker-compose.yml
- Run the following command:
docker-compose up -d
Access Grafana
- Open your web browser
- Navigate to http://localhost:3000
- Log in with these default credentials:
- Username: admin
- Password: admin
- Follow the prompts to set a new admin password
- You’ll be redirected to the Grafana dashboard
Conclusion
Congratulations! You now have Grafana running in a Docker container. You can start exploring its powerful data visualization and analytics capabilities.