Sign inSign up

loyaltyone/docker-grafana

By loyaltyone

•Updated over 8 years ago

A compact docker image with:Grafana.

Image
0

4.3K

loyaltyone/docker-grafana repository overview

⁠Graphana and Node Image

A compact docker image based on debian:jessie with:

  • Grafana (4.5.2)
  • NodeJS 8 (8.4.0)
  • Nginx
  • kms-env
  • s3-copy

In addition to having node and java installed, this image comes with kms-env⁠ installed. If you pass in environment variables encrypted using kms-env. The image will automatically decrypt them.

In order for decryption to work, your docker container must be running on an ec2-instance with a role that has access to AWS KMS (and the master key used for encryption).

Nginx is used for enabling reverse proxy for grafana.

⁠Building and Publishing

The docker image is published in Docker Hub⁠.

When code is pushed to the master branch, hooks in Docker Hub will rebuild the latest image.

⁠Running locally

⁠Build the container

docker build -t docker-grafana/latest .

⁠Run the container

⁠With embedded sqlite3 database
docker run --rm -d \
  -p 3000:3000 \
  --name=grafana \
  -e "GF_SECURITY_ADMIN_USER=admin" \
  -e "GF_SECURITY_ADMIN_PASSWORD=secret" \
  docker-grafana/latest

Notes:

  • The --rm will destroy existing container.
  • kms-env will not decrypt password when running locally.
  • Port forwarding is overridden because 80 requires root permissions.

Now you should be able to visit http://localhost:3000/.

⁠With MySQL running on host machine

Make sure MySQL configuration file has the following configuration. This is necessary so that the docker container can talk to the host.

bind-address = 0.0.0.0

Setup the user test in MySQL (the root password in this case is blank):

$ mysql -u root -p
Enter password: <ENTER>

mysql> create user 'test'@'%%' identified by 'testtest';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'test'@'%%';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

Setup a database called grafana:

$ mysql -u test -p
Enter password: testtest<ENTER>

mysql> create database grafana;
Query OK, 1 row affected (0.00 sec)

mysql> quit
Bye

Replace <host machine name or ip> with the docker host name or IP address.

host_ip=<host machine name or ip>

docker run --rm -d \
  -p 3000:3000 \
  --name=grafana \
  -e "GF_SECURITY_ADMIN_USER=admin" \
  -e "GF_SECURITY_ADMIN_PASSWORD=secret" \
  -e "GF_DATABASE_TYPE=mysql" \
  -e "GF_DATABASE_HOST=${host_ip}:3306" \
  -e "GF_DATABASE_USER=test" \
  -e "GF_DATABASE_PASSWORD=testtest" \
  -e "GF_DATABASE_NAME=grafana" \
  --net="bridge" \
  docker-grafana/latest

Now you should be able to visit `http://localhost:3000/`.

If you destroy the container and restart it, it should have persisted
information such as data sources and dashboards.

## Log into the container

```bash
docker exec -it grafana bash

⁠Destroy the container

docker rm -f grafana

Tag summary

Content type

Image

Digest

Size

174.3 MB

Last updated

over 8 years ago

docker pull loyaltyone/docker-grafana