Skip to content

Latest commit

 

History

History
196 lines (141 loc) · 6.13 KB

File metadata and controls

196 lines (141 loc) · 6.13 KB

Global Elasticsearch Stack

License: MIT

Select Language:

Russian English Spanish Chinese French German
Русский Selected Español 中文 Français Deutsch

This project provides a ready-to-use Elasticsearch + analysis-icu + analysis-phonetic + Kibana stack with an Nginx reverse proxy for easy access.

📋 Prerequisites

  • Docker 20.10+ and Docker Compose 2.0+
  • 4+ GB of free RAM
  • Ports 8080 and 9200 must be available on the host
  • Existing Docker network external_network (remove from docker-compose.yml if not needed)

🗂 Project Structure

.
├── .docker.env (created by command or manually)
├── .docker.env.example
├── .gitignore
├── docker-compose.yml
├── Makefile
├── README.md
├── langs
│   ├── ...localized README.md files...
├── assets
│   ├── ...content for README.md...
├── docker-configs
│   ├── elasticsearch
│   │   ├── Dockerfile
│   │   └── elasticsearch.yml
│   ├── kibana
│   │   ├── Dockerfile
│   │   ├── kibana.yml
│   │   └── wait-for-elastic.sh
│   └── nginx
│       ├── Dockerfile
│       └── default.conf.template
└── data
    ├── ...created for the project in .env...

⚙️ Configuration

Main environment variables (file .docker.env):

Variable Default Value Description
COMPOSE_PROJECT_NAME elasticsearch Project name
ELASTIC_VERSION latest Elasticsearch version
KIBANA_VERSION latest Kibana version
NGINX_VERSION latest Nginx version
ELASTIC_CONTAINER elasticsearch Elasticsearch container name
KIBANA_CONTAINER kibana Kibana container name
NGINX_CONTAINER nginx Nginx container name
KIBANA_DOMAIN kibana.local Domain for accessing Kibana
ELASTIC_DOMAIN elastic.local Domain for accessing Elasticsearch
KIBANA_PORT 5601 Kibana port on the host
ELASTIC_PORT 9200 Elasticsearch port on the host
NGINX_PORT 80 Nginx port on the host
ELASTIC_DATA_DIR ./data/elasticsearch Elasticsearch data storage
KIBANA_DATA_DIR ./data/kibana Kibana data storage
EXTERNAL_NETWORK external_network External Docker network

🛠 Technical Details

  • Elasticsearch:
    • Single-node cluster
    • Allocated 2GB RAM
    • Pre-installed analysis-icu plugin
    • Pre-installed analysis-phonetic plugin
    • Synonyms configuration via synonyms.txt
  • Kibana:
    • Automatic wait for Elasticsearch readiness
    • Configured reverse proxy via Nginx
  • Nginx:
    • Reverse proxy for Elasticsearch and Kibana

🚀 Quick Start

1. Clone the repository

git clone https://github.com/yourusername/docker-elasticsearch.git
cd docker-elasticsearch

2. Initialize the environment

If you are using Windows, check the Makefile for a full list of commands. It is recommended to use either Linux or Windows + WSL.

2.1 Initialize .docker.env

Run:

make init

This will create a .docker.env file and the directories for storing files (ELASTIC_DATA_DIR, KIBANA_DATA_DIR).

2.2 Download Elasticsearch, Kibana, and Nginx images

Run:

make pull

This will download images based on the versions specified in ELASTIC_VERSION, KIBANA_VERSION, NGINX_VERSION.

2.3 Start the project

Run:

make up

If you encounter an error:

network onex_backend declared as external, but could not be found

make-up-error.png

This means you did not specify an external network (the project network that Elasticsearch should connect to). Two options:

  1. Specify an existing network in .docker.env under EXTERNAL_NETWORK
  2. Remove the following from docker-compose.yml:
For the elasticsearch service:
- external_network

For networks:
external_network:
  name: ${EXTERNAL_NETWORK}
  external: true

2.4 Other commands

  • Build images without cache: make build
  • Stop containers: make down
  • "Hard" restart: make reset
  • "Soft" restart: make restart
  • Enter a specific container: make in <container>
  • View logs of a specific container: make log <container>

🔌 Service Access

After starting, services are available via Nginx:

  • Kibana: http://${KIBANA_DOMAIN}:${NGINX_PORT}
  • Elasticsearch: http://${ELASTIC_DOMAIN}:${NGINX_PORT}

By default:

Don't forget to add domains to the hosts file:

  • For Windows: C:\Windows\System32\drivers\etc\hosts
  • For Linux: /etc/hosts

Example:

127.0.0.1    elastic.local
127.0.0.1    kibana.local

Result

Access Elasticsearch via browser (http://elastic.local:80):

elastic-local-1.png

elastic-local-2.png

Access Kibana via browser (http://kibana.local:80):

kibana-local-1.png

kibana-local-2.png

kibana-local-3.png