How to generate grafana container correctly?

1

I installed the grafana container via docker as follows:

docker run -d --name=grafana \
--restart always \
-p 5000:3000 \
-e "GF_SERVER_PROTOCOL=http" \
-e "GF_SERVER_ROOT_URL=http://meuIP" \
-e "GF_SERVER_HTTP_PORT=3000" \
-v /docker/grafana/data:/var/lib/grafana \
grafana/grafana

But when I try to access it it will not go because it is not running on the IP that I want (myIP) and yes on 0.0.0.0 as shown below:

CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS                    NAMES
2c7246e98d99        grafana/grafana     "/run.sh"           About a minute ago   Up 4 seconds        0.0.0.0:5000->3000/tcp   grafana

In this case how do I route and access it by typing link in the browser?

EDIT:

I'm using CentOS7.

The version of Docker is:

Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:25 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:25 2017
 OS/Arch:      linux/amd64
 Experimental: false

Edited 2:

The problem is that from time to time the container gets status Exited (1) seconds after I run it.

If I do this, it runs and I can access:

docker run \
  -d \
  -p 5200:3000 \
  grafana/grafana

But I want to install the zabbix plugin as well. Alas, if I do it, it will take you after 10 seconds:

docker run -d \
-p 5100:3000 \
-e "GF_INSTALL_PLUGINS=alexanderzobnin-zabbix-app" \
grafana/grafana

I also want to redirect the data from the container to a specific folder so if there is anything wrong I can retrieve it.

If I do this, it also excites:

docker run \
  -d \
  -p 5200:3000 \
   -v /docker/grafana/data:/var/lib/grafana \
  grafana/grafana

But I wanted to do it like this:

docker run -d \
-p 5100:3000 \
-e "GF_INSTALL_PLUGINS=alexanderzobnin-zabbix-app" \
-v /docker/grafana/data:/var/lib/grafana \
grafana/grafana

Does anyone know why the container gets canceled when I try to install the plugin or redirect the output?

    
asked by anonymous 20.09.2018 / 16:16

1 answer

1

Given your scenario, I would recommend creating a custom image with the plugin (s) you need, rather than running this large command whenever startar your container .

Configuring Dockerfile

In the repository of grafana has a directory custom/ with a Dockerfile to customize, just do the < a href="https://github.com/grafana/grafana-docker.git"> clone and use.

Building the image

Within the cloned directory ( grafana-docker/custom/ ), construct the new image by passing the parameter:

  • the version of the grafana image used as base, in the variable GRAFANA_VERSION
  • and the plugin (s) you want to install on the variable GF_INSTALL_PLUGINS

Something like this:

docker build -t grafana:atual_com_plugins \
  --build-arg "GRAFANA_VERSION=latest" \
  --build-arg "GF_INSTALL_PLUGINS=alexanderzobnin-zabbix-app" .

Tip # 1: Instead of using tag latest always use the latest stable version, in this case version #

Starting the container

With your image built successfully, you can start normally:

docker run \
  -d \
  -p 5200:3000 \
  --name=grafana \
   -v /docker/grafana/data:/var/lib/grafana \
  grafana:atual_com_plugins

All this information is available in the installation documentation with docker .

Obs: If it still does not work, check if the plugin is ok or if it's not a problem with the graphfana versions,

EDIT: As quoted by @beto, if you want to persist data using volume, you must give permission to the directory where the data will be stored.

    
21.09.2018 / 20:47