Elasticsearch build-in users config in docker-compose

Hi, Is there any way to use "elasticsearch-setup-passwords" command in docker-compose to define build-in users and password? I don't wanna exec elasticsearch-setup-passwords interactive command manually on every container. some kind of importing users and password into container.
Thanx

Here is how I'm setting that with docker compose ( docker-compose.yml):

---
version: '3'
services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:$ELASTIC_VERSION
    environment:
      - bootstrap.memory_lock=true
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
      - ELASTIC_PASSWORD=$ELASTIC_PASSWORD
      - xpack.security.enabled=$ELASTIC_SECURITY
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200
    networks: ['stack']

  kibana:
    image: docker.elastic.co/kibana/kibana:$ELASTIC_VERSION
    environment:
      - ELASTICSEARCH_USERNAME=elastic
      - ELASTICSEARCH_PASSWORD=$ELASTIC_PASSWORD
    ports: ['5601:5601']
    networks: ['stack']
    links: ['elasticsearch']
    depends_on: ['elasticsearch']

networks:
  stack: {}

.env file is:

ELASTIC_VERSION=7.5.1
ELASTIC_SECURITY=true
ELASTIC_PASSWORD=changeme

@dadoonet Is there any way to also set password for Kibana user in elasticsearch env variables?

if you define ELASTIC_PASSWORD, it is applied to all the users IIRC, elastic and probably the others.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.