In this short tutorial, we will quickly walk you through the process of setting up a basic Grafana instance using Docker compose.
Requirements
To run the commands and steps provided in this post, ensure you have the following:
- Docker engine installed
- Docker compose installed
- Sufficient permissions to run Docker containers
Defining Docker Compose File
The first step is defining the Docker compose configuration for running the Docker container. Start by creating the directory to store the config file:
Navigate into the directory and create a file called docker-compose.yml file.
$ touch docker-compose.yml
Edit the file and add the configuration as shown:
services:
grafana:
image: grafana/grafana-enterprise
container_name: grafana
restart: unless-stopped
ports:
- '3000:3000'
volumes:
- grafana_data:/var/lib/grafana
volumes:
grafana_data: {}
In the above Docker Compose configuration file, we define all the steps and configuration for deploying a Grafana container.
We start by defining the version of the Docker compose format. We then define the Grafana service, which includes all the required services. For example, we tell Docker to use Grafana enterprise image.
We also specify other service features, such as the restart policy, port mapping to port 3000, and more.
Finally, to ensure data persistency, we create a volume named grafana_data, which stores data in /var/lib/grafana.
Running the Container
Once we are satisfied with the configuration, we can use the docker compose utility to run the container as:
Accessing Grafana
Once the containers are started, you can access the Grafana instance by navigating to the address: http://localhost:3000.
This should prompt you to provide the default credentials. Use the admin/admin combination. Once logged in, you will be forced to change the password for the admin account.
Conclusion
This tutorial covered the basics of setting up a Grafana instance by using the Docker container and the Grafana enterprise image. Feel free to reference the documentation for more details and customization.