Role Detail

Apache Solr container for Docker.
Type Container App
Minimum Ansible Container Version 0.9.2
Installation $ ansible-container init
Last Commit 2017-10-01 22:23:10 PM UTC
Last Imported 2017-11-17 21:27:09 PM UTC
Version History
Version Release Date
1.2.0 2017-09-28 04:28:04 AM
1.1.0 2017-07-14 21:54:09 PM
1.0.0 2017-07-10 03:55:03 AM
Last 10 Imports
Completed Status
2017-11-17 21:27:09 PM UTC SUCCESS
2017-11-16 21:26:09 PM UTC SUCCESS
2017-11-15 21:26:09 PM UTC SUCCESS
2017-11-13 21:25:09 PM UTC SUCCESS
2017-11-11 21:23:09 PM UTC SUCCESS
2017-11-09 21:23:09 PM UTC SUCCESS
2017-11-07 21:23:09 PM UTC SUCCESS
2017-11-06 21:21:09 PM UTC SUCCESS
2017-11-04 21:20:09 PM UTC SUCCESS
2017-11-02 21:17:09 PM UTC SUCCESS

Apache Solr (Built with Ansible Container)

Build Status

This project is in it's early stages. There will be bugs! You may be better served using the official Solr Docker image if it meets your requirements.

This project is composed of three main parts:

  • Ansible Container project: This project is maintained on GitHub: geerlingguy/solr-container. Please file issues, support requests, etc. against this GitHub repository.
  • Docker Hub Image: If you just want to use the geerlingguy/solr Docker image in your project, you can pull it from Docker Hub.
  • Ansible Role: If you need a flexible Ansible role that's compatible with both traditional servers and containerized builds, check out geerlingguy.solr on Ansible Galaxy. (This is the Ansible role that does the bulk of the work in managing the Apache Solr container.)


Currently maintained versions include:

  • 6.x, 6.6.1, latest: Apache Solr 6.x
  • 5.x, 5.5.4: Apache Solr 5.x
  • 4.x, 4.10.4: Apache Solr 4.x
  • 3.x, 3.6.2: Apache Solr 3.x

Standalone Usage

If you want to use the geerlingguy/solr image from Docker Hub, you don't need to install or use this project at all. You can quickly build a Solr container locally with:

docker run -d --name=solr -p 8983:8983 geerlingguy/solr:latest /opt/solr/bin/solr start -p 8983 -s /var/solr -f -force

(For Solr 4.x, drop the final -force argument.)

You can also wrap up that configuration in a Dockerfile and/or a docker-compose.yml file if you want to keep things simple. For example:

version: "3"

    image: geerlingguy/solr:latest
    container_name: solr
      - "8983:8983"
    restart: always
    # See 'Custom and Persistent Solr cores' for instructions for volumes.
    volumes: []
    command: ["/opt/solr/bin/solr", "start", "-p", "8983", "-s", "/var/solr", "-f", "-force"]

Then run:

docker-compose up -d

Now you should be able to access the Solr admin dashboard at http://localhost:8983/.

Custom and Persistent Solr cores

The default installation includes a collection1 core in the SOLR_HOME directory, /var/solr.

Apache Solr will autodiscover any Solr cores in SOLR_HOME by searching for files inside each subdirectory. A standard convention for a single Solr core is to to mount a host directory as a volume with the core directory, containing the core's conf, data, and files.

Here's an example minimal file, for a core named mysearch:


So, if you have a solr core directory named mysearch (with a mysearch/ file inside, and a conf and data directory for storing Solr configuration and index data, respectively), mount it as a volume like -v ./mysearch:/var/solr/mysearch:rw. If you have multiple solr cores (all defined inside a cores directory), mount them inside a cores directory like -v ./cores:/var/solr/cores.

Or, if using a Docker Compose file:

      # If you have one core:
      - ./mysearch:/var/solr/mysearch:rw
      # If you have multiple cores:
      - ./cores:/var/solr/cores:rw

You can also mount volumes from a data container or elsewhere; the key is you will be able to both provide custom Solr configuration (schema.xml, solrconfig.xml, etc.), and also have a persistent data directory that lives outside the container.

Apache Solr 3.x

There are a number of differences to keep in mind if using Apache Solr 3.x:

  • Apache Solr 3.x doesn't support or core autodiscovery, so if you want to use a custom Solr core configuration, you should mount a volume into /opt/solr/example/solr with your Solr core configuration (conf and data dirs, at minimum).
  • At this time, multicore isn't officially supported under 3.x in this Docker container.
  • Apache Solr 3.x doesn't run in the foreground in the same way as 4+. You have to use the command java -jar start.jar inside the directory /opt/solr/example to start Solr in the foreground.

Management with Ansible Container


Before using this project to build and maintain a Solr images for Docker, you need to have the following installed:

Build the image

ansible-container --var-file vars-6.x.yml build

Once the image is built, you can run docker images to see the acsolr-solr image that was generated.

Older Solr versions are also supported—specify the vars file for the version you would like to install to switch to that version of Solr.

Run the image as a container

ansible-container --var-file vars-6.x.yml run

You should be able to reach the Solr dashboard by accessing http://localhost:8983/ in your browser.

(Use stop to stop the container, and destroy to reset the containers and all images.)

Push the image to Docker Hub

Currently, the process for updating this image on Docker Hub is manual. Eventually this will be automated via Travis CI using ansible-container push (currently, this is waiting on this issue to be resolved).

  1. Log into Docker Hub on the command line:

    docker login --username=geerlingguy
  2. Tag the latest version (only if this is the latest/default version):

    docker tag [image id] geerlingguy/solr:latest
  3. Tag the Solr major version:

    docker tag [image id] geerlingguy/solr:6.x # or 5.x, 4.x, 3.x...
    docker tag [image id] geerlingguy/solr:6.6.1 # the specific version
  4. Push tags to Docker Hub:

    docker push geerlingguy/solr:latest # (if this was just tagged)
    docker push geerlingguy/solr:6.x # or 5.x, 4.x, 3.x...
    docker push geerlingguy/solr:6.6.1 # the specific version



Author Information

This container build was created in 2017 by Jeff Geerling, author of Ansible for DevOps.

version: "2"
  # The Conductor container does the heavy lifting, and provides a portable
  # Python runtime for building your target containers. It should be derived
  # from the same distribution as you're building your target containers with.
  conductor_base: debian:stretch

  # The deployment_output_path is mounted to the Conductor container, and the
  # `run` and `deployment` commands then write generated Ansible playbooks to it.
  # deployment_output_path: ./ansible-deployment

    from: "debian:stretch"
      - "8983:8983"
    working_dir: "{{ container_working_dir }}"
    command: "{{ container_start_command }}"
      - setup
      - geerlingguy.solr
        - "DEBUG=1"

    namespace: geerlingguy
    repository_prefix: ''