Install Kibana with Docker

edit

Install Kibana with Docker

edit

Docker images for Kibana are available from the Elastic Docker registry. The base image is ubuntu:20.04.

A list of all published Docker images and tags is available at www.docker.elastic.co. The source code is in GitHub.

These images contain both free and subscription features. Start a 30-day trial to try out all of the features.

Run Kibana on Docker for development

edit

To start an Elasticsearch container for development or testing, run:

docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.17.26
docker run --name es01-test --net elastic -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.17.26

To start Kibana and connect it to your Elasticsearch container, run the following commands in a new terminal session:

docker pull docker.elastic.co/kibana/kibana:7.17.26
docker run --name kib01-test --net elastic -p 127.0.0.1:5601:5601 -e "ELASTICSEARCH_HOSTS=http://es01-test:9200" docker.elastic.co/kibana/kibana:7.17.26

To access Kibana, go to http://localhost:5601.

Stop Docker containers

edit

To stop your containers, run:

docker stop es01-test
docker stop kib01-test

To remove the containers and their network, run:

docker network rm elastic
docker rm es01-test
docker rm kib01-test

Configure Kibana on Docker

edit

The Docker images provide several methods for configuring Kibana. The conventional approach is to provide a kibana.yml file as described in Configuring Kibana, but it’s also possible to use environment variables to define settings.

Bind-mounted configuration

edit

One way to configure Kibana on Docker is to provide kibana.yml via bind-mounting. With docker-compose, the bind-mount can be specified like this:

version: '2'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:7.17.26
    volumes:
      - ./kibana.yml:/usr/share/kibana/config/kibana.yml

Persist the Kibana keystore

edit

By default, Kibana auto-generates a keystore file for secure settings at startup. To persist your secure settings, use the kibana-keystore utility to bind-mount the parent directory of the keystore to the container. For example:

docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data docker.elastic.co/kibana/kibana:7.17.26 bin/kibana-keystore create
docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data docker.elastic.co/kibana/kibana:7.17.26 bin/kibana-keystore add test_keystore_setting

Environment variable configuration

edit

Under Docker, Kibana can be configured via environment variables. When the container starts, a helper process checks the environment for variables that can be mapped to Kibana command-line arguments.

For compatibility with container orchestration systems, these environment variables are written in all capitals, with underscores as word separators. The helper translates these names to valid Kibana setting names.

All information that you include in environment variables is visible through the ps command, including sensitive information.

Some example translations are shown here:

Table 1. Example Docker Environment Variables

Environment Variable

Kibana Setting

SERVER_NAME

server.name

SERVER_BASEPATH

server.basePath

ELASTICSEARCH_HOSTS

elasticsearch.hosts

In general, any setting listed in Configure Kibana can be configured with this technique.

Supplying array options can be tricky. The following example shows the syntax for providing an array to ELASTICSEARCH_HOSTS.

These variables can be set with docker-compose like this:

version: '2'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:7.17.26
    environment:
      SERVER_NAME: kibana.example.org
      ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200"]'

Since environment variables are translated to CLI arguments, they take precedence over settings configured in kibana.yml.

Docker defaults

edit

The following settings have different default values when using the Docker images:

server.host

"0.0.0.0"

server.shutdownTimeout

"5s"

elasticsearch.hosts

http://elasticsearch:9200

monitoring.ui.container.elasticsearch.enabled

true

These settings are defined in the default kibana.yml. They can be overridden with a custom kibana.yml or via environment variables.

If replacing kibana.yml with a custom version, be sure to copy the defaults to the custom file if you want to retain them. If not, they will be "masked" by the new file.