docker-solr / docker-solr-examples

Examples for Docker-Solr
Apache License 2.0
61 stars 58 forks source link

How can I connect remote solrCloud with solrJ? #9

Open zhangddjs opened 4 years ago

zhangddjs commented 4 years ago

When I try to connect solrCloud with solrJ using host ip, I found that the livenodes' ip is always the containers' ip, obviously, unreachable. How can I connect solrCloud from a remote java client?

dsmiley commented 4 years ago

I believe you have to set the SOLR_HOST env var to a client accessible hostname, and this should wind up in livenodes in ZK.

zhangddjs commented 4 years ago

okay~ I set the Solr_Host and DNS, then it succeed.

solr4:
    image: solr:7.5
    container_name: solr4
    ports:
     - "30008:30008"
    environment:
      - ZK_HOST=solr-zk1:2181,solr-zk2:2181,solr-zk3:2181
      - SOLR_PORT=30008
      - SOLR_HOST=dev.covfefe.com
    extra_hosts:
      - dev.covfefe.com:10.100.13.173
    networks:
      - solr-cloud
    depends_on:
      - solr-zk1
      - solr-zk2
      - solr-zk3
jasi110 commented 4 years ago

I'm new to this and have been trying to do similar with no luck. How did you know the IP to enter on the right of the extra_hosts statement before the containers come up? That IP is the container IP, right? Then you need to add the dev.covfefe.com host to the network outside of the containers so that your solrj host can resolve it? Thanks.

zhangddjs commented 4 years ago

Nope, that IP is the host's IP, not the container's.

jasi110 commented 4 years ago

It’s working for me now. Thank you so much!

zhangddjs commented 4 years ago

wel~~