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.

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:

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:

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 custom.sh script like:

#!/bin/bash
set -e
echo "this is running inside the container before Solr starts"

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.

About this repository

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.

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).

solr:<version>-slim

This image does not contain the common packages contained in the default tag and only contains the minimal packages needed to run solr. Unless you are working in an environment where only the solr image will be deployed and you have space constraints, we highly recommend using the default image of this repository.

License

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.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).