Search code examples
dockersolrapache-zookeepersolrcloud

how to run SolrCloud with docker-compose


Please help me with docker-compose file. Right now, i'm using Solr in docker file, but i need to change it to SolrCloud. I need 2 Solr instances, an internal Zookeeper and docker (local). This is an example of docker-compose file I did:

version: "3"

services:
  mongo:
    image: mongo:latest
    container_name: mongo
    hostname: mongo
    networks:
      - gsec
    ports:
      - 27018:27017    

  sqlserver:
    image: microsoft/mssql-server-linux:latest
    hostname: sqlserver
    container_name: sqlserver
    environment:
      SA_PASSWORD: "#Password123!"
      ACCEPT_EULA: "Y"
    networks:
      - gsec
    ports:
      - 1403:1433
  solr:
    image: solr
    container_name: solr    
    ports:
     - "8983:8983"
    networks:
      - gsec 
    volumes:
      - data:/opt/solr/server/solr/mycores
    entrypoint:
      - docker-entrypoint.sh
      - solr-precreate
      - mycore
volumes:
  data:

networks:
      gsec:
        driver: bridge

Thank you in advanced.


Solution

  • Solr docker instance has a zookeeper server embedded into. You have just to start Solr with the right parameters and add the zookeeper ports 9983:9983 in the docker-compose file:

      solr:
        image: solr
        container_name: solr    
        ports:
         - "9983:9983"
         - "8983:8983"
        networks:
          - gsec 
        volumes:
          - data:/opt/solr/server/solr/mycores
        entrypoint:
          - docker-entrypoint.sh
          - solr
          - start
          - -c
          - -f
    

    SolrCloud basically is a Solr cluster where Zookeeper is used to coordinate and configure the cluster.

    Usually you use SolrCloud with Docker because you're are learning how it works or because you're preparing your application (locally?) to deploy in a bigger environment.

    On the other hand it doesn't make much sense run SolrCloud if you don't have a distributed configuration, i.e. having Solr and Zookeeper running on different nodes.

    SolrCloud is the kind of cluster you need when you have hundred or even thousands searches per second with collection of millions or even billions of documents.

    Your cluster have to scale horizontally.