Docker is all the rage at the moment! It was recently selected as Gartner Cool Vendor in DevOps. As you may already know, Docker is a platform to build and deploy applications as self-contained units. Those units, called containers, can be executed consistently on a developer laptop or production server. Since containers include all their dependencies, they are truly portable. And, compared to normal virtual machine images, Docker containers are much more lightweight because they don’t need as much infrastructure as a normal VM. Docker containers are built from an image, a simple text file describing the steps needed to assemble and execute the container. But the goal of this blog post is not to be a Docker tutorial. In this post, we will be running SolrCloud 5 using Docker 1.7.
First, you need to pull the image:
docker pull solr
You can 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'
Create a collection:
docker exec -i -t solr1 /opt/solr/bin/solr create_collection \ -c collection1 -shards 2 -p 8983
Then go to http://localhost:8983/solr/#/~cloud (adjust the hostname for your docker host) to see the two shards and Solr nodes.