It is possible to set node.roles in docker-compose.yml?

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
opensearch 2.7.0

Describe the issue:
when I set docker-compose.yml like this

version: '3'
    container_name: ${CONTAINER_NAME}
      - node.roles=[cluster_manager]
      - network.publish_host=${NETWORK_PUBLISH_HOST}
      - network.bind_host=${NETWORK_BIND_HOST}
      - discovery.seed_hosts=${DISCOVERY_SEED_HOSTS}
      - cluster.initial_cluster_manager_nodes=${INITIAL_CLUSTER_MANAGER_NODES}
      - bootstrap.memory_lock=true # Disable JVM heap memory swapping
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM

if I set “node.roles”, I got the error

node does not have the data and cluster_manager roles but has index metadata: [/usr/share/opensearch/data/nodes/0/indices/y-1DIUXmTLSoDB6xMRhguQ/_state, /usr/share/opensearch/data/nodes/0/indices/oZj8ih5mTC6RMPNz1JoLMA/_state]. Use 'opensearch-node repurpose' tool to clean up

when I didn’t set “node.roles”, docker-compose.yml can connect

node name [os-manager-node2], node ID [***], cluster name [***], roles [ingest, remote_cluster_client, data, cluster_manager]

but I want to set a role each node.
how to set node.roles in docker-compose.yml??

Hey @cucukaka

- node.roles=[cluster_manager]

Try something like this

      - node.roles=cluster_manager
      - discovery.seed_hosts=opensearch-node1,opensearch-node2      -
      - bootstrap.memory_lock=true 
      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"

As for you log file.

node does not have the data and cluster_manager roles but has index metadata:
Use ‘opensearch-node repurpose’ tool to clean up

Seams like your missing the data and cluster manager roles. not sure what going on with your containers.

It lead me here elasticsearch-node | Elasticsearch Guide [8.11] | Elastic

@cucukaka Extra comment to @Gsmitt’s post.
When you run a node without assigned role it will automatically assign default roles which includes manager and data roles.
If you stop the container and limit the roles it will produce the observed error as it will find index metadata from the previous run.

If this is POC then you can try from scratch and delete the corresponding volumes. Next configure preferred node roles and start containers.

Please be aware that cluster requires at least one data node and master node.

1 Like

thanks, it is right.
first I follow this command
Use 'opensearch-node repurpose' tool to clean up

but there are no file in there

so I deleted volumes in docker-compose.yml
and docker-compose.yml was up again
node’s role changed