I created a simple elasticsearch "cluster" on my local machine (mac) using docker-compose. The config is seen below
version: '2.2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    environment:
      - cluster.name=elasticsearch
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "index.number_of_replicas: 1"
      - "index.number_of_shards: 2"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet
volumes:
  esdata1:
    driver: local
networks:
  esnet:
Now I would like to add a new es node to this cluster, but I am not sure how to proceed. I have tried to run a docker container with the command:
docker run -e "cluster.name=elasticsearch" -e "bootstrap.memory_lock: true" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "discovery.zen.ping.unicast.hosts=localhost:9200" -e "network.host: _local_"  -v esdata2:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:6.2.4
But this seems to create a separate cluster/node because when I try and access http://127.0.0.1:9200/_cluster/health?pretty I still see only one node:
{
  "cluster_name" : "elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 1,
  "active_shards" : 1,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
I'm not sure how else I should create the new es node and add it to my cluster. Do I need to use docker-compose again or are the flags that I specified in my docker run incorrect?
 
     
     
    