Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a local kibana in a container

Tags:

docker

kibana

I am trying to run use kibana console with my local elasticsearch (container) In the ElasticSearch documentation I see

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.2.2

Which lets me run the community edition in a quick one liner.

Looking at the kibana documentation i see only

docker pull docker.elastic.co/kibana/kibana:6.2.2

Replacing pull with run it looks for the x-pack (I think it means not community) and fails to find the ES

Unable to revive connection: http://elasticsearch:9200/

Is there a one liner that could easily set up kibana localy in a container? All I need is to work with the console (Sense replacement)

like image 947
Bick Avatar asked Mar 03 '18 19:03

Bick


People also ask

How do I run Kibana locally?

For this, go to the folder where Kibana is unpacked. Once you see the ready signal in the console, you can open Kibana in browser using http://localhost:5601/.The default port on which kibana is available is 5601.


2 Answers

If you want to use kibana with elasticsearch locally with docker, they have to communicate with each other. To do so, according to the doc, you need to link the containers. You can give a name to the elasticsearch container with --name:

docker run \
  --name elasticsearch_container \
  --publish 9200:9200 \
  --publish 9300:9300 \
  --env "discovery.type=single-node" \
  docker.elastic.co/elasticsearch/elasticsearch:6.2.2

And then link this container to kibana:

docker run \
  --name kibana \
  --publish 5601:5601 \
  --link elasticsearch_container:elasticsearch_alias \
  --env "ELASTICSEARCH_URL=http://elasticsearch_alias:9200" \
  docker.elastic.co/kibana/kibana:6.2.2

The port 5601 is exposed locally to access it from your browser. You can check in the monitoring section that elasticsearch's health is green.

EDIT (24/03/2020):

The option --link may eventually be removed and is now a legacy feature of docker. The idiomatic way of reproduce the same thing is to firstly create a user-defined bridge:

docker network create elasticsearch-kibana

And then create the containers inside it:

 Version 6

docker run \
  --name elasticsearch_container \
  --network elasticsearch-kibana \
  --publish 9200:9200 \
  --publish 9300:9300 \
  --env "discovery.type=single-node" \
  docker.elastic.co/elasticsearch/elasticsearch:6.2.2
docker run \
  --name kibana \
  --publish 5601:5601 \
  --network elasticsearch-kibana \
  --env "ELASTICSEARCH_URL=http://elasticsearch_container:9200" \
  docker.elastic.co/kibana/kibana:6.2.2

Version 7

As it was pointed out, the environment variable changed for the version 7. It now is ELASTICSEARCH_HOSTS.

docker run \
  --name elasticsearch_container \
  --network elasticsearch-kibana \
  --publish 9200:9200 \
  --publish 9300:9300 \
  --env "discovery.type=single-node" \
  docker.elastic.co/elasticsearch/elasticsearch:7.6.2
docker run \
  --name kibana \
  --publish 5601:5601 \
  --network elasticsearch-kibana \
  --env "ELASTICSEARCH_HOSTS=http://elasticsearch_container:9200" \
  docker.elastic.co/kibana/kibana:7.6.2

User-defined bridges provide automatic DNS resolution between containers that means you can access each other by their container names.

like image 101
L. Meyer Avatar answered Oct 07 '22 15:10

L. Meyer


It is convenient to use docker-compose as well.
For instance, the file below, stored in home directory, allows to start Kibana with one command:
docker-compose up -d:

# docker-compose.yml

version: "2"
 kibana:
    image: "docker.elastic.co/kibana/kibana:6.2.2"
    container_name: "kibana"
    environment:
      - "ELASTICSEARCH_URL=http://<elasticsearch-endpoint>:9200"
      - "XPACK_GRAPH_ENABLED=false"
      - "XPACK_ML_ENABLED=false"
      - "XPACK_REPORTING_ENABLED=false"
      - "XPACK_SECURITY_ENABLED=false"
      - "XPACK_WATCHER_ENABLED=false"
    ports:
      - "5601:5601"
    restart: "unless-stopped"

In addition, Kibana service might be a part of your project in development environment (in case, docker-compose is used).

like image 5
antonbormotov Avatar answered Oct 07 '22 15:10

antonbormotov