Official Repository

Last pushed: 18 days ago
Short Description
Solr is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene™.
Full Description

Supported tags and respective Dockerfile links

For more information about this image and its history, please see the relevant manifest file (library/solr). This image is updated via pull requests to the docker-library/official-images GitHub repo.

For detailed information about the virtual/transfer sizes and individual layers of each of the above supported tags, please see the repos/solr/tag-details.md file in the docker-library/repo-info GitHub repo.

What is Solr?

Solr is highly reliable, scalable and fault tolerant, providing distributed indexing, replication and load-balanced querying, automated failover and recovery, centralized configuration and more. Solr powers the search and navigation features of many of the world's largest internet sites.

Learn more on Apache Solr homepage and in the Apache Solr Reference Guide.

wikipedia.org/wiki/Apache_Solr

How to use this Docker image

Run Solr and index example data

To run a single Solr server:

$ docker run --name my_solr -d -p 8983:8983 -t solr

Then with a web browser go to http://localhost:8983/ to see the Admin Console (adjust the hostname for your docker host).

To use Solr, you need to create a "core", an index for your data. For example:

$ docker exec -it --user=solr my_solr bin/solr create_core -c gettingstarted

In the web UI if you click on "Core Admin" you should now see the "gettingstarted" core.

If you want to load some of the example data that is included in the container:

$ docker exec -it --user=solr my_solr bin/post -c gettingstarted example/exampledocs/manufacturers.xml

In the UI, find the "Core selector" popup menu and select the "gettingstarted" core, then select the "Query" menu item. This gives you a default search for *:* which returns all docs. Hit the "Execute Query" button, and you should see a few docs with data. Congratulations!

Single-command demo

For convenience, there is a single command that starts Solr, creates a collection called "demo", and loads sample data into it:

$ docker run --name solr_demo -d -P solr solr-demo

Loading your own data

If you want load your own data, you'll have to make it available to the container, for example by copying it into the container:

$ docker cp $HOME/mydata/mydata.xml my_solr:/opt/solr/mydata.xml
$ docker exec -it --user=solr my_solr bin/post -c gettingstarted mydata.xml

or by using Docker host volumes:

$ docker run --name my_solr -d -p 8983:8983 -t -v $HOME/mydata:/opt/solr/mydata solr
$ docker exec -it --user=solr my_solr bin/solr create_core -c gettingstarted
$ docker exec -it --user=solr my_solr bin/post -c gettingstarted mydata/mydata.xml

To learn more about Solr, see the Apache Solr Reference Guide.

Creating Cores

In addition to the docker exec method explained above, you can create a core automatically at start time, in several ways.

If you run:

$ docker run -d -P solr solr-create -c mycore

the container will:

  • run Solr in the background, on the loopback interface
  • wait for it to start
  • run the "solr create" command with the arguments you passed
  • stop the background Solr
  • start Solr in the foreground

You can combine this with mounted volumes to pass in core configuration from your host:

$ docker run -d -P -v $PWD/myconfig:/myconfig solr solr-create -c mycore -d /myconfig

When using the solr-create command, Solr will log to the standard docker log (inspect with docker logs), and the collection creation will happen in the background and log to /opt/docker-solr/init.log.

This first way closely mirrors the manual core creation steps and uses Solr's own tools to create the core, so should be reliable.

The second way of creating a core at start time is using the solr-precreate command. This will create the core in the filesystem before running Solr. You should pass it the core name, and optionally the directory to copy the config from (this defaults to Solr's built-in "basic_configs"). For example:

$ docker run -d -P solr solr-precreate mycore
$ docker run -d -P -v $PWD/myconfig:/myconfig solr solr-precreate mycore /myconfig

This method stores the core in an intermediate subdirectory called "mycores". This allows you to use mounted volumes:

$ mkdir mycores
$ sudo chown 8983:8983 mycores
$ docker run -d -P -v $PWD/mycores:/opt/solr/server/solr/mycores solr solr-precreate mycore

This second way is quicker, easier to monitor because it logs to the docker log, and can fail immediately if something is wrong. But, because it makes assumptions about Solr's "basic_configs", future upstream changes could break that.

The third way of creating a core at startup is to use the image extension mechanism explained in the next section.

Using Docker Compose

With Docker Compose you can create a Solr container with the index stored in a named data volume. Create a docker-compose.yml like:

version: '2'
services:
  solr:
    image: solr
    ports:
     - "8983:8983"
    volumes:
      - data:/opt/solr/server/solr/mycores
    entrypoint:
      - docker-entrypoint.sh
      - solr-precreate
      - mycore
volumes:
  data:

and just run docker-compose up.

Extending the image

The docker-solr image has an extension mechanism. At run time, before starting Solr, the container will execute scripts in the /docker-entrypoint-initdb.d/ directory. You can add your own scripts there either by using mounted volumes or by using a custom Dockerfile. These scripts can for example copy a core directory with pre-loaded data for continuous integration testing, or modify the Solr configuration.

Here is a simple example. With a set-heap.sh script like:

#!/bin/bash
set -e
cp /opt/solr/bin/solr.in.sh /opt/solr/bin/solr.in.sh.orig
sed -e 's/SOLR_HEAP=".*"/SOLR_HEAP="1024m"/' </opt/solr/bin/solr.in.sh.orig >/opt/solr/bin/solr.in.sh
grep '^SOLR_HEAP=' /opt/solr/bin/solr.in.sh

you can run:

$ docker run --name solr_heap1 -d -P -v $PWD/docs/set-heap.sh:/docker-entrypoint-initdb.d/set-heap.sh solr
$ sleep 5
$ docker logs solr_heap1 | head
/opt/docker-solr/scripts/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/set-heap.sh
SOLR_HEAP="1024m"


Starting Solr on port 8983 from /opt/solr/server

With this extension mechanism it can be useful to see the shell commands that are being executed by the docker-entrypoint.sh script in the docker log. To do that, set an environment variable using Docker's -e VERBOSE=yes.

Distributed Solr

You can also run a distributed Solr configuration.

The recommended and most flexible way to do that is to use Docker networking. See the Can I run ZooKeeper and Solr clusters under Docker FAQ, and this example.

You can also use legacy links, see the Can I run ZooKeeper and Solr with Docker Links FAQ.

About this repository

This repository is available on github.com/docker-solr/docker-solr, and the official build is on the Docker Hub.

This repository is based on (and replaces) makuk66/docker-solr, and has been sponsored by Lucidworks.

Image Variants

The solr images come in many flavors, each designed for a specific use case.

solr:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

solr:alpine

This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

This variant is highly recommended when final image size being as small as possible is desired. The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements. However, most software doesn't have an issue with this, so this variant is usually a very safe choice. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.

To minimize image size, it's uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine image description for examples of how to install packages if you are unfamiliar).

License

Solr is licensed under the Apache License, Version 2.0.

This repository is also licensed under the Apache License, Version 2.0.

Copyright 2015 Martijn Koster

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Supported Docker versions

This image is officially supported on Docker version 1.13.1.

Support for older versions (down to 1.6) is provided on a best-effort basis.

Please see the Docker installation documentation for details on how to upgrade your Docker daemon.

User Feedback

Issues

Please report issues with this docker image on this Github project.

For general questions about Solr, see the Community information, in particular the solr-user mailing list.

Contributing

If you want to contribute to Solr, see the Solr Resources.

Docker Pull Command

Comments (4)
makuk66
8 months ago

Please use the https://github.com/docker-solr/docker-solr project for questions and issues, rather than this page.

@deeksha25: I've created https://github.com/docker-solr/docker-solr/issues/40 for your particular question.

deeksha25
9 months ago

This zookeeper image does not recognize the solr instances other than the one that is running on port 8983. What I mean by that is if you run the 2 solr instances (eg Node1 on port 8983 and Node2 on port 8984), the number of alive_nodes on Admin UI still shows 8983
Why is it so?

makuk66
a year ago

Please use the https://github.com/docker-solr/docker-solr project for questions and issues, rather than this page.

dinusubba: I've created https://github.com/docker-solr/docker-solr/issues/3 for your particular question.

dinusubba
a year ago

How to start the zookeeper in an ensemble mode and if we have multiple zookeeper hosts, how can we link all of them to solr nodes