Solr on Docker
14 Aug 2013
/Looking for an up-to-date solr docker image? See/ makuk66/docker-solr
I ran into one minor issue: docker failed with a "/var/run/docker.sock: permission denied" error due to a bug which has a workaround of:
sudo chmod 777 /var/run/docker.sock
Next we'll prepare an image to run Solr, similar to the solr tutorial.
First, download Solr, to the docker host:
then create a trivial Dockerfile (see Dockerfile Builder docs):
cat > Dockerfile <<EOM # # VERSION 0.1 FROM ubuntu MAINTAINER Martijn Koster "firstname.lastname@example.org" RUN mkdir -p /opt ADD solr-4.4.0.tgz /opt/solr-4.4.0.tgz RUN tar -C /opt --extract --file /opt/solr-4.4.0.tgz RUN apt-get update RUN apt-get --yes install openjdk-6-jdk EXPOSE 8983 CMD ["/bin/bash", "-c", "cd /opt/solr-4.4.0/example; java -jar start.jar"] EOM
Then create the template:
docker build -t makuk66/solr4 .
And run it:
docker run makuk66/solr4
which starts executing Solr in about a second. You can see what port was used for the port forwarding with:
mak@macro:~$ docker ps ID IMAGE COMMAND CREATED STATUS PORTS 7e7806800146 makuk66/solr4:latest /bin/bash -c cd /opt 3 hours ago Up 3 hours 49153->8983
so I could connect to
http://macro.lan:49153/solr and found Solr running.
I can see changes made in the container with
docker diff 7e7806800146,
and export files from the container with e.g.
docker export 7e7806800146 | tar xvf - ./opt/solr-4.4.0/example/logs/solr.log.
I also tried the Virtualbox/Vagrant method on my MacBook Pro but ran into some issues:
git cloneI needed to modify the Vagrantfile because of a VirtualBox conflict:
config.vm.forward_port 4243, 1234
Because of the VirtualBox setup, to get access from my Mac (and other hosts on the LAN), I needed to add a NAT port mapping in VirtualBox (Settings -> Network -> Port Forwarding, I added a mapping from 49153 -> 49153). With that in place, I can get to Solr on http://localhost:49153/solr/#/
I get to Solr, but the UI is broken; it looks like the
I gave up on that for now and switched back to my Linux server.
I can imagine this setup might be useful in clean-slate component testing. Most of my integration test deployments are specifically for clusters on multi-VM configurations, which this seems less suited for. There is obviously a good use-case for this in isolating web serving, though I'll hold off on that until the release a production-ready version. It will be interesting keeping an eye on the docker blog to see what other applications turn up.
Update: See a follow-up post on Search Hub: SolrCloud on Docker