dockerelasticsearchdocker-composekibanalocked

Elasticsearch via docker-compose - Warning: "this node is locked into cluster UUID..."


I start services in a local cluster via docker compose. Two docker containers are from the example of elasticsearch. I get following error in the console from the elasticsearch:

elasticsearch_instance | 
{
  "@timestamp":"2024-07-11T07:39:09.788Z", 
  "log.level": "WARN", 
  "message": "this node is locked into cluster UUID [fxwqYYLsTdy-C7AmpycuLA] but [cluster.initial_master_nodes] is set to [35794ba3f6c5]; remove this setting to avoid possible data loss caused by subsequent cluster bootstrap attempts", 
  "ecs.version": "1.2.0",
  "service.name": "ES_ECS",
  "event.dataset": "elasticsearch.server",
  "process.thread.name": "main",
  "log.logger": "org.elasticsearch.cluster.coordination.ClusterBootstrapService",
  "elasticsearch.node.name": "35794ba3f6c5",
  "elasticsearch.cluster.name": "docker-cluster"
}

My docker-compose.yml looks like this:

elasticsearch:
  container_name: "elasticsearch_instance"
  image: elasticsearch:8.3.2
  environment:
    - discovery.type=single-node
    - ES_JAVA_OPTS=-Xms1g -Xmx1g
    - xpack.security.enabled=false
  volumes:
    - es_data:/usr/share/elasticsearch/data
    - /home/xxx/configs/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
  ports:
    - 9200:9200
  networks:
    elastic-network:
      aliases:
        - myDb
kibana:
  image: kibana:8.3.2
  ports:
    - target: 5601
      published: 5601
  depends_on:
    - elasticsearch
networks:
  elastic-network:
    driver: bridge

The id "35794ba3f6c5" from above is the ID of the docker container. The ID "fxwqYYLsTdy-C7AmpycuLA" seems to be created by elasticsearch newly at every startup. The warning implies cluster.initial_master_nodes should not be set to resolve this warning. However, I did not set/apply this setting anywhere.

My elasticsearch.yml looks like this:

$ cat /usr/share/elasticsearch/config/elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
xpack.security.enabled: false

Does someone know if the solution is to unset cluster.initial_master_nodes, or if there is another solution to this?

The effect I see is that logs do not appear in elasticsearch and I suspect it is because of this warning since it tells to remove this setting to avoid possible data loss.


Solution

    1. The solution was to delete all existing docker containers using:

      docker container prune

    2. To delete the content of the data folder in

      /usr/share/elasticsearch/data

    which can be done by changing the name of "es_data" to something else e.g., "es_data1". Otherwise it seems the data is persisted.