Enable Authentication in elasticsearch with docker environment variable

anne picture anne · Jun 13, 2018 · Viewed 13.2k times · Source

I would like to ask how will I be able to enable authentication (x-pack). In my case I am using docker image of elasticsearch v.6.2.4. My problem is that xpack is installed but it is not asking for credentials.

Thank you for your help!

I know that xpack is installed because of this in my kibana enter image description here

Answer

S. Wasta picture S. Wasta · Feb 22, 2020

Maybe I came too late... but I had this problem today and digging found tha you don't have to set the user, just the password. This is the docker-compose file

version: '3.6'
services:
  elasticsearchNode:
    image: elasticsearch:$STACK_VERSION
    container_name: elasticsearchNode
    environment:
      discovery.type: 'single-node'
      ELASTIC_PASSWORD: $ELK_PASS
      cluster.name: 'dockercluster'
      node.name: 'node-master'
      bootstrap.memory_lock: 'true'
      ES_JAVA_OPTS: '-Xms512m -Xmx512m'
      xpack.security.enabled: 'true'
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - docker_elk_node
volumes:
  esdataNode:
networks:
  docker_elk_node:


and the .env file

COMPOSE_PROJECT_NAME=es
STACK_VERSION=7.6.0
ELK_PASS=MyPassWord