1

How do i enable basic authentication for kibana and elasticsearch on docker container?

I want to have authentication enabled in kibana. With the normal files we can simply set the flag xpack.security.enabled=true and generate the password but since i am running elasticsearch and kibana on docker how do i do it ?? This is my current docker file

version: '3.7'

services:
  elasticsearch:
    image: elasticsearch:7.9.2
    ports:
      - '9200:9200'
    environment:
      - discovery.type=single-node
    ulimits:
      memlock:
        soft: -1
        hard: -1
  kibana:
    image: kibana:7.9.2
    ports:
      - '5601:5601'

1 Answer 1

2

You can pass it in env vars while running docker run command for elasticsearch. Something like this:

docker run -p 9200:9200 -p 9300:9300 -e "xpack.security.enabled=true" docker.elastic.co/elasticsearch/elasticsearch:7.14.0
Sign up to request clarification or add additional context in comments.

6 Comments

This must be run everytime i run docker? right?
@Tushar you can create a Dockerfile with this cmd
isnt there any permanent solution?? like we do it locally for a node elastic.yml
@Tushar yes you can do it using docker compose, set environment variable in docker-compose file. Follow this for more info elastic.co/guide/en/elastic-stack-get-started/current/…
Thanks ! where do i add the run command in my docker file??
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.