You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by fg...@apache.org on 2019/01/12 01:19:00 UTC

[incubator-sdap-nexus] 04/04: Overhauled Solr images. Includes new Solr Cloud image and init container.

This is an automated email from the ASF dual-hosted git repository.

fgreg pushed a commit to branch SDAP-166
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git

commit 91b15ce0b123d652eaa1f5eb589a835ae3e77ceb
Author: Frank Greguska <fr...@jpl.nasa.gov>
AuthorDate: Fri Jan 11 17:16:16 2019 -0800

    Overhauled Solr images. Includes new Solr Cloud image and init container.
---
 docker/solr/Dockerfile                             |  10 +-
 docker/solr/Readme.rst                             |  21 ++--
 docker/solr/{cloud => cloud-init}/Dockerfile       |  23 ++---
 docker/solr/cloud-init/Readme.rst                  |  73 ++++++++++++++
 docker/solr/cloud-init/create-collection.py        | 111 +++++++++++++++++++++
 docker/solr/cloud/Dockerfile                       |  15 ++-
 docker/solr/cloud/Readme.rst                       |  65 ++++++++----
 .../0-init-home.sh}                                |  10 +-
 .../1-bootstrap-zk.sh}                             |   5 +-
 docker/solr/cloud/tmp/solr.xml                     |  53 ++++++++++
 docker/solr/cloud/tmp/zoo.cfg                      |  31 ++++++
 docker/solr/singlenode/Dockerfile                  |  13 ++-
 docker/solr/singlenode/Readme.rst                  |  10 +-
 .../bootstrap-zk.sh => singlenode/create-core.sh}  |   9 +-
 14 files changed, 380 insertions(+), 69 deletions(-)

diff --git a/docker/solr/Dockerfile b/docker/solr/Dockerfile
index fb4a8f0..e7cd99d 100644
--- a/docker/solr/Dockerfile
+++ b/docker/solr/Dockerfile
@@ -17,21 +17,19 @@ MAINTAINER Apache SDAP "dev@sdap.apache.org"
 
 USER root
 
-ENV SOLR_HOME="/usr/local/solrhome"
+ENV SOLR_HOME=/opt/solr/server/solr
 
-WORKDIR /
-RUN set -e; \
-    rm -rf /opt/solr/server/solr/mycores && \
+RUN cd / && \
     apt-get update && \
     apt-get -y install git sudo && \
     rm -rf /var/lib/apt/lists/* && \
     git clone https://github.com/apache/incubator-sdap-nexus.git && \
-    cp -r /incubator-sdap-nexus/data-access/config/schemas/solr/nexustiles /opt/solr/server/solr/nexustiles && \
+    cp -r /incubator-sdap-nexus/data-access/config/schemas/solr/nexustiles /tmp/nexustiles && \
     rm -rf /incubator-sdap-nexus && \
     wget http://central.maven.org/maven2/org/locationtech/jts/jts-core/1.15.1/jts-core-1.15.1.jar && \
     cp jts-core-1.15.1.jar /opt/solr/server/solr-webapp/webapp/WEB-INF/lib/jts-core-1.15.1.jar && \
     chown ${SOLR_USER}:${SOLR_GROUP} /opt/solr/server/solr-webapp/webapp/WEB-INF/lib/jts-core-1.15.1.jar && \
     rm jts-core-1.15.1.jar
 
-WORKDIR /opt/solr
+
 USER ${SOLR_USER}
diff --git a/docker/solr/Readme.rst b/docker/solr/Readme.rst
index e4acecd..6ecbe5b 100644
--- a/docker/solr/Readme.rst
+++ b/docker/solr/Readme.rst
@@ -1,3 +1,5 @@
+.. _solr_images:
+
 Solr Images
 =====================
 
@@ -8,14 +10,15 @@ Common Environment Variables
 
 Any environment variable that can be passed to `solr.in.sh <https://github.com/apache/lucene-solr/blob/95d01c6583b825b6b87591e4f27002c285ea25fb/solr/bin/solr.in.sh>`_ and be passed as an environment variable to the docker container and it will be utilized. A few options are called out here:
 
-========================  ========================  =============
-       Variable               Default               Description
-========================  ========================  =============
-``SOLR_HEAP``              ``localhost``            Increase Java Heap as needed to support your indexing / query needs
-``SOLR_HOME``              ``/usr/local/solrhome``  Path to a directory for Solr to store cores and their data.
+``SOLR_HEAP``
+    *default: 512m*
+
+    Increase Java Heap as needed to support your indexing / query needs
 
-                                                    This directory is exposed as a ``VOLUME`` that can be mounted.
-========================  ========================  =============
+``SOLR_HOME``
+    *default /opt/solr/server/solr*
+
+    Path to a directory for Solr to store cores and their data. This directory is exposed as a ``VOLUME`` that can be mounted.
 
 If you want to mount the ``SOLR_HOME`` directory to a directory on the host machine, you need to provide the container path to the docker run ``-v`` option. Doing this allows you to retain the index between start/stop of this container.
 
@@ -36,8 +39,10 @@ This image can be built by:
 How to Run
 ^^^^^^^^^^
 
-This image is not intended to be run directly
+This image is not intended to be run directly.
 
 .. include:: ../docker/solr/singlenode/Readme.rst
 
 .. include:: ../docker/solr/cloud/Readme.rst
+
+.. include:: ../docker/solr/cloud-init/Readme.rst
diff --git a/docker/solr/cloud/Dockerfile b/docker/solr/cloud-init/Dockerfile
similarity index 64%
copy from docker/solr/cloud/Dockerfile
copy to docker/solr/cloud-init/Dockerfile
index baf42d1..1bb7644 100644
--- a/docker/solr/cloud/Dockerfile
+++ b/docker/solr/cloud-init/Dockerfile
@@ -13,20 +13,19 @@
 # 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.
-ARG tag_version=latest
-FROM sdap/solr:${tag_version}
+
+FROM python:3
 MAINTAINER Apache SDAP "dev@sdap.apache.org"
 
-WORKDIR /opt/solr
-VOLUME ${SOLR_HOME}
+ENV MINIMUM_NODES="1" \
+    SDAP_ZK_SOLR="localhost:2181/solr" \
+    SDAP_SOLR_URL="http://localhost:8983/solr/" \
+    ZK_LOCK_GUID="c4d193b1-7e47-4b32-a169-a596463da0f5" \
+    MAX_RETRIES="30" \
+    CREATE_COLLECTION_PARAMS="name=nexustiles&collection.configName=nexustiles&numShards=1"
 
-ENV INIT_SOLR_HOME="yes" \
-    SDAP_ZK_SERVICE_HOST="localhost" \
-    SDAP_ZK_SERVICE_PORT="2181" \
-    SDAP_ZK_SOLR_CHROOT="solr" \
-    SOLR_HOST="localhost"
 
-COPY ./cloud/bootstrap-zk.sh /docker-entrypoint-initdb.d/bootstrap-zk.sh
+RUN pip install kazoo==2.6.0 requests==2.21.0
+COPY ./cloud-init/create-collection.py /tmp/create-collection.py
 
-ENTRYPOINT ["docker-entrypoint.sh"]
-CMD ["solr-foreground"]
+ENTRYPOINT ["/tmp/create-collection.py"]
diff --git a/docker/solr/cloud-init/Readme.rst b/docker/solr/cloud-init/Readme.rst
new file mode 100644
index 0000000..e8a9548
--- /dev/null
+++ b/docker/solr/cloud-init/Readme.rst
@@ -0,0 +1,73 @@
+.. _solr_cloud_init:
+
+sdap/solr-cloud-init
+--------------------
+
+This image can be used to automatically create the ``nexustiles`` collection in SolrCloud.
+
+How To Build
+^^^^^^^^^^^^
+
+This image can be built from the incubator/sdap/solr directory:
+
+.. code-block:: bash
+
+    docker build -t sdap/solr-cloud-init:${BUILD_VERSION} -f cloud-init/Dockerfile .
+
+How to Run
+^^^^^^^^^^
+
+This image is designed to run in a container alongside the :ref:`solr_cloud` container. The purpose is to detect if there are at least ``MINIMUM_NODES`` live nodes in the cluster. If there are, then detect if the ``nexustiles`` collection exists or not. If it does not, this script will create it using the parameters defined by the ``CREATE_COLLECTION_PARAMS`` environment variable. See the reference documents for the `create <http://lucene.apache.org/solr/guide/7_4/collections-api.html#cr [...]
+
+.. note::
+
+	The ``action=CREATE`` parameter is already passed for you and should not be part of ``CREATE_COLLECTION_PARAMS``
+
+.. note::
+
+  This image was designed to be long running. It will only exit if there was an error detecting or creating the ``nexustiles`` collection.
+
+
+Environment Variables
+""""""""""""""""""""""""""""""""""""
+
+``MINIMUM_NODES``
+    *default: 1*
+
+    The minimum number of nodes that must be 'live' before the collection is created.
+
+``SDAP_ZK_SOLR``
+    *default: localhost:2181/solr*
+
+    The host:port/chroot of the zookeeper being used by SolrCloud.
+
+``SDAP_SOLR_URL``
+    *default: http://localhost:8983/solr/*
+
+    The URL that should be polled to check if a SolrCloud node is running. This should be the URL of the :ref:`solr_cloud` container that is being started alongside this container.
+``ZK_LOCK_GUID``
+    *default: c4d193b1-7e47-4b32-a169-a596463da0f5*
+
+    A GUID that is used to create a lock in zookeeper so that if more than one of these init containers are started at the same time, only one will attempt to create the collection. This GUID should be the same across all containers that are trying to create the same collection.
+
+``MAX_RETRIES``
+    *default: 30*
+
+    The number of times we will try to connect to SolrCloud at ``SDAP_SOLR_URL``. This is roughly equivalent to how many seconds we will wait for the node at ``SDAP_SOLR_URL`` to become available. If ``MAX_RETRIES`` is exceeded, the container will exit with an error.
+
+``CREATE_COLLECTION_PARAMS``
+    *default: name=nexustiles&collection.configName=nexustiles&numShards=1*
+
+    The parameters sent to the collection create function. See the reference documents for the `create <http://lucene.apache.org/solr/guide/7_4/collections-api.html#create>`_ function for the Solr collections API for valid parameters.
+
+
+Example Run
+"""""""""""""""
+
+Assuming Zookeeper is running on the host machine port 2181, and a :ref:`solr_cloud` container is also running with port 8983 mapped to the host machine, the easiest way to run this image is:
+
+.. code-block:: bash
+
+    docker run -it --rm --name init -e SDAP_ZK_SOLR="host.docker.internal:2181/solr" -e SDAP_SOLR_URL="http://host.docker.internal:8983/solr/" sdap/solr-cloud-init:${BUILD_VERSION}
+
+After running this image, the ``nexustiles`` collection should be available on the SolrCloud installation. Check the logs for the container to see details.
diff --git a/docker/solr/cloud-init/create-collection.py b/docker/solr/cloud-init/create-collection.py
new file mode 100755
index 0000000..f8f98bc
--- /dev/null
+++ b/docker/solr/cloud-init/create-collection.py
@@ -0,0 +1,111 @@
+#!/usr/local/bin/python -u
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+import os
+import requests
+import requests.exceptions
+import json
+import json.decoder
+import time
+import sys
+import logging
+from kazoo.client import KazooClient
+
+logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt="%Y-%m-%dT%H:%M:%S", stream=sys.stdout)
+
+MAX_RETRIES = int(os.environ["MAX_RETRIES"])
+SDAP_ZK_SOLR = os.environ["SDAP_ZK_SOLR"]
+SDAP_SOLR_URL = os.environ["SDAP_SOLR_URL"]
+ZK_LOCK_GUID = os.environ["ZK_LOCK_GUID"]
+MINIMUM_NODES = int(os.environ["MINIMUM_NODES"])
+CREATE_COLLECTION_PARAMS = os.environ["CREATE_COLLECTION_PARAMS"]
+
+def get_cluster_status():
+    try:
+        return requests.get("{}admin/collections?action=CLUSTERSTATUS".format(SDAP_SOLR_URL)).json()
+    except (requests.exceptions.ConnectionError, json.decoder.JSONDecodeError):
+        return False
+
+logging.info("Attempting to aquire lock from {}".format(SDAP_ZK_SOLR))
+zk_host, zk_chroot = SDAP_ZK_SOLR.split('/')
+zk = KazooClient(hosts=zk_host)
+zk.start()
+zk.ensure_path(zk_chroot)
+zk.chroot = zk_chroot
+lock = zk.Lock("/collection-creator", ZK_LOCK_GUID)
+try:
+    with lock:  # blocks waiting for lock acquisition
+        logging.info("Lock aquired. Checking for SolrCloud at {}".format(SDAP_SOLR_URL))
+        # Wait for MAX_RETRIES for the entire Solr cluster to be available.
+        attempts = 0
+        status = None
+        collection_exists = False
+        while attempts <= MAX_RETRIES:
+            status = get_cluster_status()
+            if not status:
+                # If we can't get the cluster status, my Solr node is not running
+                attempts += 1
+                logging.info("Waiting for Solr at {}".format(SDAP_SOLR_URL))
+                time.sleep(1)
+                continue
+            else:
+                # If we can get the cluster status, at least my Solr node is running
+                # We can check if the collection exists already now
+                if 'collections' in status['cluster'] and 'nexustiles' in status['cluster']['collections']:
+                    # Collection already exists. Break out of the while loop
+                    collection_exists = True
+                    logging.info("nexustiles collection already exists.")
+                    break
+                else:
+                    # Collection does not exist, but need to make sure number of expected nodes are running
+                    live_nodes = status['cluster']['live_nodes']
+                    if len(live_nodes) < MINIMUM_NODES:
+                        # Not enough live nodes
+                        logging.info("Found {} live node(s). Expected at least {}. Live nodes: {}".format(len(live_nodes), MINIMUM_NODES, live_nodes))
+                        attempts += 1
+                        time.sleep(1)
+                        continue
+                    else:
+                        # We now have a full cluster, ready to create collection.
+                        logging.info("Detected full cluster of at least {} nodes. Checking for nexustiles collection".format(MINIMUM_NODES))
+                        break
+
+        # Make sure we didn't exhaust our retries
+        if attempts > MAX_RETRIES:
+            raise RuntimeError("Exceeded {} retries while waiting for at least {} nodes to become live for {}".format(MAX_RETRIES, MINIMUM_NODES, SDAP_SOLR_URL))
+
+        # Full cluster, did not exceed retries. Check if collection already exists
+        if not collection_exists:
+            # Collection does not exist, create it.
+            create_command = "{}admin/collections?action=CREATE&{}".format(SDAP_SOLR_URL, CREATE_COLLECTION_PARAMS)
+            logging.info("Creating collection with command {}".format(create_command))
+            create_response = requests.get(create_command).json()
+            if 'failure' not in create_response:
+                # Collection created, we're done.
+                logging.info("Collection created. {}".format(create_response))
+                pass
+            else:
+                # Some error occured while creating the collection
+                raise RuntimeError("Could not create collection. Received response: {}".format(create_response))
+finally:
+    zk.stop()
+    zk.close()
+
+# We're done, do nothing forever.
+logging.info("Done.")
+while True:
+    time.sleep(987654321)
diff --git a/docker/solr/cloud/Dockerfile b/docker/solr/cloud/Dockerfile
index baf42d1..79dfdd1 100644
--- a/docker/solr/cloud/Dockerfile
+++ b/docker/solr/cloud/Dockerfile
@@ -17,16 +17,15 @@ ARG tag_version=latest
 FROM sdap/solr:${tag_version}
 MAINTAINER Apache SDAP "dev@sdap.apache.org"
 
-WORKDIR /opt/solr
-VOLUME ${SOLR_HOME}
-
-ENV INIT_SOLR_HOME="yes" \
-    SDAP_ZK_SERVICE_HOST="localhost" \
+ENV SDAP_ZK_SERVICE_HOST="localhost" \
     SDAP_ZK_SERVICE_PORT="2181" \
     SDAP_ZK_SOLR_CHROOT="solr" \
     SOLR_HOST="localhost"
 
-COPY ./cloud/bootstrap-zk.sh /docker-entrypoint-initdb.d/bootstrap-zk.sh
+COPY ./cloud/docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/
+COPY ./cloud/tmp/* /tmp/
 
-ENTRYPOINT ["docker-entrypoint.sh"]
-CMD ["solr-foreground"]
+# This will run docker-entrypoint.sh with the value of CMD as default arguments. However, if any arguments are supplied
+# to the docker run command when launching this image, the command line arguments will override these CMD arguments
+ENTRYPOINT ["/bin/bash", "-c", "docker-entrypoint.sh $(eval echo $@)", "$@"]
+CMD ["solr-foreground", "-c", "-z ${SDAP_ZK_SERVICE_HOST}:${SDAP_ZK_SERVICE_PORT}/${SDAP_ZK_SOLR_CHROOT}"]
diff --git a/docker/solr/cloud/Readme.rst b/docker/solr/cloud/Readme.rst
index b0b7bc4..ae71a2e 100644
--- a/docker/solr/cloud/Readme.rst
+++ b/docker/solr/cloud/Readme.rst
@@ -1,7 +1,9 @@
+.. _solr_cloud:
+
 sdap/solr-cloud
 --------------------
 
-This is the cloud version of Solr.
+This image runs SolrCloud.
 
 How To Build
 ^^^^^^^^^^^^
@@ -19,37 +21,49 @@ This Docker container runs Apache Solr v7.4 in cloud mode with the nexustiles co
 
 It is necessary to decide wether or not you want data to persist when the container is stopped or if the data should be discarded.
 
+.. note::
+
+  There are multiple times that ``host.docker.internal`` is used in the example ``docker run`` commands provided below. This is a special DNS name that is known to work on Docker for Mac for `connecting from a container to a service on the host <https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host>`_. If you are not launching the container with Docker for Mac, there is no guarantee that this DNS name will be resolvable inside the  [...]
+
 Cloud Specific Environment Variables
 """"""""""""""""""""""""""""""""""""
 
-========================  ===============  =============
-       Variable               Default       Description
-========================  ===============  =============
-``SDAP_ZK_SERVICE_HOST``   ``localhost``    This is the hostname of the Zookeeper service that Solr should use to connect.
-``SDAP_ZK_SERVICE_PORT``   ``2181``         The port Solr should try to connect to Zookeeper with.
-``SDAP_ZK_SOLR_CHROOT``    ``solr``         The Zookeeper chroot under which Solr configuration will be accessed.
-``SOLR_HOST``              ``localhost``    The hostname of the Solr instance that will be recored in Zookeeper.
-========================  ===============  =============
+``SDAP_ZK_SERVICE_HOST``
+    *default: localhost*
+
+    This is the hostname of the Zookeeper service that Solr should use to connect.
+
+``SDAP_ZK_SERVICE_PORT``
+    *default: 2181*
+
+    The port Solr should try to connect to Zookeeper with.
+
+``SDAP_ZK_SOLR_CHROOT``
+    *default: solr*
+
+    The Zookeeper chroot under which Solr configuration will be accessed.
+
+``SOLR_HOST``
+    *default: localhost*
+
+    The hostname of the Solr instance that will be recored in Zookeeper.
 
 Zookeeper
 """"""""""""
 
 Zookeeper can be running on the host machine or anywhere that docker can access (e.g. a bridge network). Take note of the host where Zookeeper is running and use that value for the ``SDAP_ZK_SERVICE_HOST`` environment variable.
 
-.. note::
-
-	If you choose to run Zookeeper on the host machine and you are using Docker For Mac, you can use the special hostname ``host.docker.internal`` to access the host from inside a container.
-
 
 Persist Data
-""""""""""""
+""""""""""""""""
+
+To persist the data, we need to provide a volume mount from the host machine to the container path where the collection data is stored. By default, collection data is stored in the location indicated by the ``$SOLR_HOME`` environment variable. If you do not provide a custom ``SOLR_HOME`` location, the default is ``/opt/solr/server/solr``.
 
-If you want to persist the data between runs, provide a volume mount from the host machine to the container path where ``SOLR_HOME`` is. If you do not provide a custom ``SOLR_HOME`` location, the default is ``/usr/local/solrhome``.
-This also assumes you are running Zookeeper on the host machine and that you are using Docker for Mac.
+Assuming Zookeeper is running on the host machine port 2181, the easiest way to run this image and persist data to a location on the host machine is:
 
 .. code-block:: bash
 
-    docker run --name solr -v ${PWD}/solrhome:/usr/local/solrhome -p 8083:8083 -d -e SDAP_ZK_SERVICE_HOST="host.docker.internal" sdap/solr-cloud:${VERSION}
+    docker run --name solr -v ${PWD}/solrhome:/opt/solr/server/solr -p 8983:8983 -d -e SDAP_ZK_SERVICE_HOST="host.docker.internal" -e SOLR_HOST="host.docker.internal" sdap/solr-cloud:${VERSION}
 
 ``${PWD}/solrhome`` is the directory on host machine where ``SOLR_HOME`` will be created if it does not already exist.
 
@@ -57,10 +71,23 @@ Don't Persist Data
 """"""""""""""""""
 
 If you do not need to persist data between runs of this image, just simply run the image without a volume mount.
-This also assumes you are running Zookeeper on the host machine and that you are using Docker for Mac.
+
+Assuming Zookeeper is running on the host machine port 2181, the easiest way to run this image without persisting data is:
 
 .. code-block:: bash
 
-    docker run --name solr -p 8083:8083 -d -e SDAP_ZK_SERVICE_HOST="host.docker.internal" sdap/solr-cloud:${VERSION}
+    docker run --name solr -p 8983:8983 -d -e SDAP_ZK_SERVICE_HOST="host.docker.internal" -e SOLR_HOST="host.docker.internal" sdap/solr-cloud:${VERSION}
 
 When the container is removed, the data will be lost.
+
+Collection Initialization
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Solr Collections must be created after at least one SolrCloud node is live. When a collection is created, by default Solr will attempt to spread the shards across all of the live nodes at the time of creation. This poses two problems
+
+1) The nexustiles collection can not be created during a "bootstrapping" process in this image.
+2) The nexustiles collection should not be created until an appropriate amount of nodes are live.
+
+A helper container has been created to deal with these issues. See :ref:`solr_cloud_init` for more details.
+
+The other option is to create the collection manually after starting as many SolrCloud nodes as desired. This can be done through the Solr Admin UI or by utilizing the `admin collections API <http://lucene.apache.org/solr/guide/7_4/collections-api.html#collections-api>`_.
diff --git a/docker/solr/cloud/bootstrap-zk.sh b/docker/solr/cloud/docker-entrypoint-initdb.d/0-init-home.sh
similarity index 80%
copy from docker/solr/cloud/bootstrap-zk.sh
copy to docker/solr/cloud/docker-entrypoint-initdb.d/0-init-home.sh
index c8dc2aa..149c660 100755
--- a/docker/solr/cloud/bootstrap-zk.sh
+++ b/docker/solr/cloud/docker-entrypoint-initdb.d/0-init-home.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -ex
+#!/bin/bash
 
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -17,6 +17,10 @@
 
 set -ex
 
-ZK_HOST="${SDAP_ZK_SERVICE_HOST}:${SDAP_ZK_SERVICE_PORT}/${SDAP_ZK_SOLR_CHROOT}"
+if [ ! -f ${SOLR_HOME}/solr.xml ]; then
+    cp /tmp/solr.xml ${SOLR_HOME}
+fi
 
-./server/scripts/cloud-scripts/zkcli.sh -zkhost ${ZK_HOST} -cmd bootstrap -solrhome ${SOLR_HOME}
+if [ ! -f ${SOLR_HOME}/zoo.cfg ]; then
+    cp /tmp/zoo.cfg ${SOLR_HOME}
+fi
diff --git a/docker/solr/cloud/bootstrap-zk.sh b/docker/solr/cloud/docker-entrypoint-initdb.d/1-bootstrap-zk.sh
similarity index 85%
copy from docker/solr/cloud/bootstrap-zk.sh
copy to docker/solr/cloud/docker-entrypoint-initdb.d/1-bootstrap-zk.sh
index c8dc2aa..cbabbda 100755
--- a/docker/solr/cloud/bootstrap-zk.sh
+++ b/docker/solr/cloud/docker-entrypoint-initdb.d/1-bootstrap-zk.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -ex
+#!/bin/bash
 
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -19,4 +19,5 @@ set -ex
 
 ZK_HOST="${SDAP_ZK_SERVICE_HOST}:${SDAP_ZK_SERVICE_PORT}/${SDAP_ZK_SOLR_CHROOT}"
 
-./server/scripts/cloud-scripts/zkcli.sh -zkhost ${ZK_HOST} -cmd bootstrap -solrhome ${SOLR_HOME}
+./bin/solr zk upconfig -z ${ZK_HOST} -n nexustiles -d /tmp/nexustiles
+./bin/solr zk cp -z ${ZK_HOST} ${SOLR_HOME}/solr.xml zk:/solr.xml
diff --git a/docker/solr/cloud/tmp/solr.xml b/docker/solr/cloud/tmp/solr.xml
new file mode 100644
index 0000000..4a79fe2
--- /dev/null
+++ b/docker/solr/cloud/tmp/solr.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+
+<!--
+   This is an example of a simple "solr.xml" file for configuring one or
+   more Solr Cores, as well as allowing Cores to be added, removed, and
+   reloaded via HTTP requests.
+
+   More information about options available in this configuration file,
+   and Solr Core administration can be found online:
+   http://wiki.apache.org/solr/CoreAdmin
+-->
+
+<solr>
+
+  <solrcloud>
+
+    <str name="host">${host:}</str>
+    <int name="hostPort">${jetty.port:8983}</int>
+    <str name="hostContext">${hostContext:solr}</str>
+
+    <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
+
+    <int name="zkClientTimeout">${zkClientTimeout:30000}</int>
+    <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
+    <int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
+    <str name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
+    <str name="zkACLProvider">${zkACLProvider:org.apache.solr.common.cloud.DefaultZkACLProvider}</str>
+
+  </solrcloud>
+
+  <shardHandlerFactory name="shardHandlerFactory"
+    class="HttpShardHandlerFactory">
+    <int name="socketTimeout">${socketTimeout:600000}</int>
+    <int name="connTimeout">${connTimeout:60000}</int>
+  </shardHandlerFactory>
+
+</solr>
diff --git a/docker/solr/cloud/tmp/zoo.cfg b/docker/solr/cloud/tmp/zoo.cfg
new file mode 100644
index 0000000..7e42d8c
--- /dev/null
+++ b/docker/solr/cloud/tmp/zoo.cfg
@@ -0,0 +1,31 @@
+# The number of milliseconds of each tick
+tickTime=2000
+# The number of ticks that the initial
+# synchronization phase can take
+initLimit=10
+# The number of ticks that can pass between
+# sending a request and getting an acknowledgement
+syncLimit=5
+
+# the directory where the snapshot is stored.
+# dataDir=/opt/zookeeper/data
+# NOTE: Solr defaults the dataDir to <solrHome>/zoo_data
+
+# the port at which the clients will connect
+# clientPort=2181
+# NOTE: Solr sets this based on zkRun / zkHost params
+
+# the maximum number of client connections.
+# increase this if you need to handle more clients
+#maxClientCnxns=60
+#
+# Be sure to read the maintenance section of the
+# administrator guide before turning on autopurge.
+#
+# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
+#
+# The number of snapshots to retain in dataDir
+#autopurge.snapRetainCount=3
+# Purge task interval in hours
+# Set to "0" to disable auto purge feature
+#autopurge.purgeInterval=1
diff --git a/docker/solr/singlenode/Dockerfile b/docker/solr/singlenode/Dockerfile
index e514e8b..10021e0 100644
--- a/docker/solr/singlenode/Dockerfile
+++ b/docker/solr/singlenode/Dockerfile
@@ -1,4 +1,3 @@
-
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.
@@ -17,9 +16,15 @@ ARG tag_version=latest
 FROM sdap/solr:${tag_version}
 MAINTAINER Apache SDAP "dev@sdap.apache.org"
 
-WORKDIR /opt/solr
-VOLUME ${SOLR_HOME}
-ENV INIT_SOLR_HOME="yes"
+USER root
+
+RUN echo "${SOLR_USER} ALL=(ALL) NOPASSWD: /usr/bin/cp -r /tmp/nexustiles/* ${SOLR_HOME}/nexustiles/" >> /etc/sudoers && \
+    echo "${SOLR_USER} ALL=(ALL) NOPASSWD: /usr/bin/chown -R ${SOLR_USER}\:${SOLR_GROUP} ${SOLR_HOME}/nexustiles" >> /etc/sudoers
+
+COPY ./singlenode/create-core.sh /docker-entrypoint-initdb.d/0-create-core.sh
+
+USER ${SOLR_USER}
+VOLUME ${SOLR_HOME}/nexustiles
 
 ENTRYPOINT ["docker-entrypoint.sh"]
 CMD ["solr-foreground"]
diff --git a/docker/solr/singlenode/Readme.rst b/docker/solr/singlenode/Readme.rst
index 2b8c94a..0f814f2 100644
--- a/docker/solr/singlenode/Readme.rst
+++ b/docker/solr/singlenode/Readme.rst
@@ -1,3 +1,5 @@
+.. _solr_singlenode:
+
 sdap/solr-singlenode
 --------------------
 
@@ -20,13 +22,13 @@ This Docker container runs Apache Solr v7.4 as a single node with the nexustiles
 Persist Data
 """"""""""""
 
-To persist the data, we need to provide a volume mount from the host machine to the container path where ``SOLR_HOME`` is. If you do not provide a custom ``SOLR_HOME`` location, the default is ``/usr/local/solrhome``. Therefore, the easiest way to run this image and persist data to a location on the host machine is:
+To persist the data in the ``nexustiles`` collection, we need to provide a volume mount from the host machine to the container path where the collection data is stored. By default, collection data is stored in the location indicated by the ``$SOLR_HOME`` environment variable. If you do not provide a custom ``SOLR_HOME`` location, the default is ``/opt/solr/server/solr``. Therefore, the easiest way to run this image and persist data to a location on the host machine is:
 
 .. code-block:: bash
 
-    docker run --name solr -v ${PWD}/solrhome:/usr/local/solrhome -p 8083:8083 -d sdap/solr-singlenode:${VERSION}
+    docker run --name solr -v ${PWD}/solrhome/nexustiles:/opt/solr/server/solr/nexustiles -p 8083:8083 -d sdap/solr-singlenode:${BUILD_VERSION}
 
-``${PWD}/solrhome`` is the directory on host machine where ``SOLR_HOME`` will be created if it does not already exist. If you have run this container before and ``${PWD}/solrhome`` already contains files, those files will not be overwritten and will be used.
+``${PWD}/solrhome/nexustiles`` is the directory on host machine where the ``nexustiles`` collection will be created if it does not already exist. If you have run this container before and ``${PWD}/solrhome/nexustiles`` already contains files, those files will *not* be overwritten. In this way, it is possible to retain data on the host machine between runs of this docker image.
 
 Don't Persist Data
 """"""""""""""""""
@@ -35,6 +37,6 @@ If you do not need to persist data between runs of this image, just simply run t
 
 .. code-block:: bash
 
-    docker run --name solr -p 8083:8083 -d sdap/solr-singlenode:${VERSION}
+    docker run --name solr -p 8083:8083 -d sdap/solr-singlenode:${BUILD_VERSION}
 
 When the container is removed, the data will be lost.
diff --git a/docker/solr/cloud/bootstrap-zk.sh b/docker/solr/singlenode/create-core.sh
similarity index 78%
rename from docker/solr/cloud/bootstrap-zk.sh
rename to docker/solr/singlenode/create-core.sh
index c8dc2aa..a2f6e38 100755
--- a/docker/solr/cloud/bootstrap-zk.sh
+++ b/docker/solr/singlenode/create-core.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -ex
+#!/bin/bash
 
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -17,6 +17,9 @@
 
 set -ex
 
-ZK_HOST="${SDAP_ZK_SERVICE_HOST}:${SDAP_ZK_SERVICE_PORT}/${SDAP_ZK_SOLR_CHROOT}"
+SOLR_HOME=${SOLR_HOME:=/opt/solr/server/solr/}
+mkdir -p ${SOLR_HOME}/nexustiles
+sudo cp -r /tmp/nexustiles/* ${SOLR_HOME}/nexustiles/
+sudo chown -R ${SOLR_USER}:${SOLR_GROUP} ${SOLR_HOME}/nexustiles
 
-./server/scripts/cloud-scripts/zkcli.sh -zkhost ${ZK_HOST} -cmd bootstrap -solrhome ${SOLR_HOME}
+set +x