shane lee
shane lee

Reputation: 1300

Docker scale and elasticsearch

The public docker image for elasticsearch is on docker hub https://hub.docker.com/_/elasticsearch/

If i defined my own docker-compose file with elasticsearch, how would i scale up elasticsearch so that the ports don't collide?

     version: '2'

    services:
      elasticsearch:
        image: elasticsearch:latest
        ports:
          - "9200:9200"
          - "9300:9300"
  kibana:
    image: kibana
    ports:
      - 5601:5601
    environment:
      - ELASTICSEARCH_URL=http://elasticsearch:9200

How could i scale this up, similar to the command below?

docker-compose scale elasticsearch=3 

I am running docker beta for mac version 1.12.

Thanks, Shane.

Upvotes: 1

Views: 744

Answers (1)

Nguyen Sy Thanh Son
Nguyen Sy Thanh Son

Reputation: 5376

If you just want the ports don't collide, we should use "automatic port mapping" with docker-compose.yml as below:

version: '2'

services:
  elasticsearch:
    image: elasticsearch:latest
    ports:
      - 9200
      - 9300

So Docker will automatically map ports 9200 and 9300 to random ports in range 32xxx.

Upvotes: 1

Related Questions