title: How to create a solr core using docker-solrs image extension mechanism?
body: <p>I would like to create a docker image of solr that creates a core on startup. Therefore I'm using the <a href="https://hub.docker.com/_/solr/" rel="noreferrer"><code>docker-entrypoint-initdb.d</code> extension mechanism</a> described for solr docker containers. The documentation says </p>
  
  <blockquote>
    <p>The third way of creating a core at startup is to use the image
    extension mechanism explained in the next section.</p>
  </blockquote>
  
  <p>But it does not explain exactly how to achieve this.</p>
  
  <p>The Dockerfile I'm using is:</p>
  
  <pre><code>FROM solr:6.6
  
  USER root
  
  RUN mkdir /A12Core &amp;&amp; chown -R solr:solr /A12Core
  
  COPY --chown=solr:solr ./services-core/search/A12Core /A12Core/
  COPY --chown=solr:solr ./create-a12core.sh /docker-entrypoint-initdb.d/
  
  USER solr
  
  RUN chmod -R a+X /A12Core
  </code></pre>
  
  <p>The folder <code>A12Core</code> contains the solr config files for the core. And the script <code>create-a12core.sh</code> to create the core is:</p>
  
  <pre><code>#!/bin/bash
  
  solr-precreate A12Core /A12Core
  </code></pre>
  
  <p>The <code>/A12Core</code> dir contains the following files:</p>
  
  <pre><code>./core.properties
  ./conf
  ./conf/update-script.js
  ./conf/mapping-ISOLatin1Accent.txt
  ./conf/schema.xml
  ./conf/spellings.txt
  ./conf/solrconfig.xml
  ./conf/currency.xml
  ./conf/mapping-FoldToASCII.txt
  ./conf/_schema_analysis_stopwords_english.json
  ./conf/stopwords.txt
  ./conf/synonyms.txt
  ./conf/elevate.xml
  ./conf/lang
  ./conf/lang/stopwords_en.txt
  ./conf/lang/stopwords_de.txt
  </code></pre>
  
  <p>However when starting an image build with the above Dockerfile and script an infinite loop seems to be created. The output is:</p>
  
  <pre><code>/opt/docker-solr/scripts/solr-foreground: running /docker-entrypoint-initdb.d/create-a12core.sh
  Executing /opt/docker-solr/scripts/solr-precreate A12Core /A12Core
  /opt/docker-solr/scripts/solr-precreate: running /docker-entrypoint-initdb.d/create-a12core.sh
  Executing /opt/docker-solr/scripts/solr-precreate A12Core /A12Core
  /opt/docker-solr/scripts/solr-precreate: running /docker-entrypoint-initdb.d/create-a12core.sh
  Executing /opt/docker-solr/scripts/solr-precreate A12Core /A12Core
  /opt/docker-solr/scripts/solr-precreate: running /docker-entrypoint-initdb.d/create-a12core.sh
  ...
  </code></pre>
  
  <p>How do I create a core using the <code>docker-entrypoint-initdb.d</code> extension mechanism?</p>