├── README.md ├── docker-compose.yml ├── elasticsearch ├── Dockerfile └── elasticsearch.yml ├── kibana ├── Dockerfile └── kibana.yml └── nginx ├── Dockerfile └── nginx.conf /README.md: -------------------------------------------------------------------------------- 1 | # DockerComposeElasticsearch 2 | 3 | 4 | 5 | ## Overview 6 | Create a multi-node Elasticsearch cluster with Kibana and NGINX using Docker Compose on a single server 7 | 8 | Tutorial: [Deploy a Multi-node Elasticsearch Cluster with Docker Compose](https://cdn4.iconfinder.com/data/icons/social-media-2210/24/Medium-512.png]) 9 | 10 | ## Run 11 | `docker-compose up -d` 12 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | services: 3 | 4 | elasticsearch01: 5 | build: 6 | context: elasticsearch/ 7 | args: 8 | ELK_VERSION: ${ELK_VERSION:-7.10.1} 9 | volumes: 10 | - type: bind 11 | source: ./elasticsearch/elasticsearch.yml 12 | target: /usr/share/elasticsearch/config/elasticsearch.yml 13 | read_only: true 14 | #- ${ELASTICSEARCH_DATA:-/data}/elasticsearch01:/usr/share/elasticsearch/data 15 | ports: 16 | - "9200:9200" 17 | - "9300:9300" 18 | environment: 19 | - node.name=elasticsearch01 20 | - discovery.seed_hosts=elasticsearch02 21 | - cluster.initial_master_nodes=elasticsearch01,elasticsearch02 22 | - bootstrap.memory_lock=true 23 | #- "ES_JAVA_OPTS=-Xms${ES_HEAP_SIZE:-2g} -Xmx${ES_HEAP_SIZE:-2g}" 24 | ulimits: 25 | memlock: 26 | soft: -1 27 | hard: -1 28 | 29 | elasticsearch02: 30 | build: 31 | context: elasticsearch/ 32 | args: 33 | ELK_VERSION: ${ELK_VERSION:-7.10.1} 34 | volumes: 35 | - type: bind 36 | source: ./elasticsearch/elasticsearch.yml 37 | target: /usr/share/elasticsearch/config/elasticsearch.yml 38 | read_only: true 39 | #- ${ELASTICSEARCH_DATA:-/data}/elasticsearch02:/usr/share/elasticsearch/data 40 | environment: 41 | - node.name=elasticsearch02 42 | - discovery.seed_hosts=elasticsearch01 43 | - cluster.initial_master_nodes=elasticsearch01,elasticsearch02 44 | - bootstrap.memory_lock=true 45 | #- "ES_JAVA_OPTS=-Xms${ES_HEAP_SIZE:-2g} -Xmx${ES_HEAP_SIZE:-2g}" 46 | ulimits: 47 | memlock: 48 | soft: -1 49 | hard: -1 50 | 51 | kibana: 52 | build: 53 | context: kibana/ 54 | args: 55 | ELK_VERSION: ${ELK_VERSION:-7.10.1} 56 | volumes: 57 | - type: bind 58 | source: ./kibana/kibana.yml 59 | target: /usr/share/kibana/config/kibana.yml 60 | read_only: true 61 | ports: 62 | - 5601:5601 63 | depends_on: 64 | - elasticsearch01 65 | - elasticsearch02 66 | 67 | web_server: 68 | build: 69 | context: ./nginx 70 | restart: always 71 | ports: 72 | - 80:80 73 | volumes: 74 | - ./nginx/nginx.conf:/etc/nginx/nginx.conf 75 | -------------------------------------------------------------------------------- /elasticsearch/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ELK_VERSION 2 | 3 | FROM docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION} -------------------------------------------------------------------------------- /elasticsearch/elasticsearch.yml: -------------------------------------------------------------------------------- 1 | cluster.name: "docker-cluster" 2 | network.host: 0.0.0.0 3 | 4 | # License 5 | xpack.license.self_generated.type: basic 6 | 7 | # Monitoring 8 | xpack.monitoring.collection.enabled: true 9 | -------------------------------------------------------------------------------- /kibana/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ELK_VERSION 2 | 3 | # https://www.docker.elastic.co/ 4 | FROM docker.elastic.co/kibana/kibana:${ELK_VERSION} -------------------------------------------------------------------------------- /kibana/kibana.yml: -------------------------------------------------------------------------------- 1 | server: 2 | name: "elk" 3 | host: "0.0.0.0" 4 | port: 5601 5 | basePath: /kibana 6 | rewriteBasePath: true 7 | 8 | # When enabling encryption between Kibana and Elasticsearch, change "http" to "https" below: 9 | elasticsearch.hosts: ["http://elasticsearch01:9200"] 10 | 11 | xpack.monitoring.ui.container.elasticsearch.enabled: true 12 | 13 | csp.strict: false 14 | -------------------------------------------------------------------------------- /nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | 3 | # -- Install Utilities 4 | RUN apk add --no-cache bash 5 | 6 | # -- Upload NGINX configuration 7 | RUN rm /etc/nginx/nginx.conf 8 | COPY nginx.conf /etc/nginx/nginx.conf 9 | 10 | # -- Expose Ports (for documentation) 11 | EXPOSE 80 12 | 13 | # -- Start NGINX 14 | CMD ["/bin/bash", "-c", "nginx -g \"daemon off;\""] 15 | -------------------------------------------------------------------------------- /nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes auto; 2 | 3 | events { 4 | 5 | } 6 | 7 | http { 8 | 9 | default_type application/octet-stream; 10 | include /etc/nginx/mime.types; 11 | 12 | error_log /etc/nginx/error_log.log; 13 | 14 | server { 15 | 16 | listen 80 default_server; 17 | 18 | resolver 127.0.0.11 valid=30s; 19 | 20 | server_name localhost; 21 | 22 | access_log /var/log/nginx/access.log; 23 | error_log /var/log/nginx/error.log; 24 | 25 | include /etc/nginx/mime.types; 26 | 27 | location / { 28 | # We can proxy to some other service or serve some static files here 29 | } 30 | 31 | # Kibana 32 | location /kibana { 33 | 34 | #auth_basic "Restricted Access"; 35 | #auth_basic_user_file /etc/nginx/htpasswd.users; 36 | 37 | set $upstream http://kibana:5601; 38 | proxy_pass $upstream; 39 | proxy_redirect off; 40 | proxy_buffering off; 41 | 42 | proxy_http_version 1.1; 43 | proxy_pass_header Authorization; 44 | proxy_set_header Connection "Keep-Alive"; 45 | proxy_set_header Proxy-Connection "Keep-Alive"; 46 | } 47 | 48 | 49 | } 50 | 51 | 52 | } 53 | --------------------------------------------------------------------------------