如何使用Docker Elk Stack设置Kibana用户凭证

时间:2019-03-20 09:03:19

标签: docker docker-compose docker-swarm elastic-stack elasticsearch-x-pack

如何使用docker麋鹿堆栈容器为kibana gui设置登录凭据。

必须在docker-compose.yaml文件中传递哪些参数和环境变量才能使该功能正常工作。

1 个答案:

答案 0 :(得分:0)

#1.For setting kibana gui user credentials for docker elk stack, we have to set "xpack.security.enabled: true" either in elasticsearch.yml file or pass this as a environment variable in docker-compose.yml file

#2.Pass username & password as environment variable in docker-compose.yml for elasticsearch service like below 



        version: '3.3'

        services:


          elasticsearch:

            image: docker.elastic.co/elasticsearch/elasticsearch:6.6.1
            ports:
              - "9200:9200"
              - "9300:9300"
            configs:
              - source: elastic_config
                target: /usr/share/elasticsearch/config/elasticsearch.yml
            environment:
              ES_JAVA_OPTS: "-Xmx256m -Xms256m"
              ELASTIC_USERNAME: "elastic"
              ELASTIC_PASSWORD: "MyPw123"
              http.cors.enabled: "true"
              http.cors.allow-origin: "*"
              xpack.security.enabled: "true"
            networks:
              - elk
            deploy:
              mode: replicated
              replicas: 1
          logstash:
            image: docker.elastic.co/logstash/logstash:6.6.1
            ports:
              - "5044:5044"
              - "9600:9600"
            configs:
              - source: logstash_config
                target: /usr/share/logstash/config/logstash.yml:rw
              - source: logstash_pipeline
                target: /usr/share/logstash/pipeline/logstash.conf
            environment:`enter code here`
            LS_JAVA_OPTS: "-Xmx256m -Xms256m"
            xpack.monitoring.elasticsearch.url: "elasticsearch:9200"
            xpack.monitoring.elasticsearch.username: "elastic"
            xpack.monitoring.elasticsearch.password: "MyPw123"
            networks:
              - elk
            deploy:
              mode: replicated
              replicas: 1

          kibana:
            image: docker.elastic.co/kibana/kibana:6.6.1
            ports:
              - "5601:5601"
            configs:
              - source: kibana_config
                target: /usr/share/kibana/config/kibana.yml


             networks:
               - elk
             deploy:
               mode: replicated
               replicas: 1

        configs:

          elastic_config:
            file: ./elasticsearch/config/elasticsearch.yml
          logstash_config:
            file: ./logstash/config/logstash.yml
          logstash_pipeline:
            file: ./logstash/pipeline/logstash.conf
          kibana_config:
            file: ./kibana/config/kibana.yml

        networks:
          elk:
            driver: overlay


#3. add this following lines in kibana.yml file
 ---
 ## Default Kibana configuration from kibana-docker.
 from https://github.com/elastic/kibana- 
 docker/blob/master/build/kibana/config/kibana.yml
 #
   server.name: kibana
   server.host: "0"
   elasticsearch.url: http://elasticsearch:9200
   elasticsearch.username: "elastic"
   elasticsearch.password: "MyPw123" 


 #4. then go to browser with localhost:5601->management->LicenseManagement 
 (underElasticsearch) and select trial or update your license.