Start Solr cloud on Docker Swarm (1.12) without Zookeeper

I am running Docker Swarm 1.12 on 3 CoreOS machines via Vagrant.

What is the best way to start a Solr cloud on the cluster?
Do I need Zookeeper?

  • Jenkins build Docker raise error Unrecognized field “ExecDriver”
  • Why won't my container run?
  • How to access files downloaded on my windows machine from boot2docker?
  • Concourse ci resolve docker hostname
  • Restart Docker Container (Automatically) when Image changes in Portainer(?)
  • Fetching AWS instance metadata from within Docker container?
  • I have gotten as far as this:

    docker service create --mode=global --name solr -p 8983:8983 solr:5.3.1 bash -c "/opt/solr/bin/solr start -f -c"

    But then the Cloud is empty because it does not know about the other 2 machines, how can I use Swarm’s power here?

  • How to access Docker daemon through tcp-socker?
  • Installing Jenkins Plugins to Docker Jenkins
  • How to run headless Firefox profile manager? How run Firefox profile manager in docker?
  • How to enable CLI history in docker container?
  • Remotely create a vhost on a docker container running rabbitmq
  • How to change the version of Ruby in a Docker image (replace 2.2.0 with 2.0.0 )
  • One Solution collect form web for “Start Solr cloud on Docker Swarm (1.12) without Zookeeper”


    The container image documentation describes how interconnect Zookeeper as a backing store for a distributed Solr setup:

    You can also run a distributed Solr configuration, with Solr nodes in
    separate containers, sharing a single ZooKeeper server:

    Run ZooKeeper, and define a name so we can link to it:

    $ docker run --name zookeeper -d -p 2181:2181 -p 2888:2888 -p 3888:3888 jplock/zookeeper

    Run two Solr nodes, linked to the zookeeper container:

    $ docker run --name solr1 --link zookeeper:ZK -d -p 8983:8983 \
          solr \
          bash -c '/opt/solr/bin/solr start -f -z $ZK_PORT_2181_TCP_ADDR:$ZK_PORT_2181_TCP_PORT'
    $ docker run --name solr2 --link zookeeper:ZK -d -p 8984:8983 \
          solr \
          bash -c '/opt/solr/bin/solr start -f -z $ZK_PORT_2181_TCP_ADDR:$ZK_PORT_2181_TCP_PORT'

    Running distributed Solr on Docker Swarm

    Starting with a 3 node swarm:

    $ docker node ls
    2wkpmybf4wni8wia1s46lm2ml *  node1     Ready   Active        Leader
    ajrnf5oibgm7b12ayy0hg5i32    node3     Ready   Active        
    bbe8n1hybhruhhrhmswn7fjmd    node2     Ready   Active  

    Create a network

    $ docker network create --driver overlay my-net

    Start a zookeeper service and wait for it to start

    $ docker service create --name zookeeper --replicas 1 --network my-net jplock/zookeeper

    Start 2 solr instances configured to connect to the DNS address “zookeeper”. For more information on swarm mode networking you can read the documentation

    $ docker service create --name solr --replicas 2 --network my-net -p 8983:8983 \
       solr \
       bash -c '/opt/solr/bin/solr start -f -z zookeeper:2181'

    The web UI will be available on any node in the cluster

    If you check the services you’ll notice the containers are spread across all 3 nodes in the cluster. This is the default scheduling behaviour

    $ docker service ps zookeeper
    ID                         NAME         IMAGE             NODE   DESIRED STATE  CURRENT STATE          ERROR
    3fhipbsd4jdazmx8d7zum0ohp  zookeeper.1  jplock/zookeeper  node1  Running        Running 7 minutes ago  
    $ docker service ps solr
    ID                         NAME    IMAGE  NODE   DESIRED STATE  CURRENT STATE           ERROR
    bikggwpyz5q6vdxrpqwevlwsr  solr.1  solr   node2  Running        Running 43 seconds ago  
    cutbmjsmcxrmi1ld75eox0s9m  solr.2  solr   node3  Running        Running 43 seconds ago  
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.