I would like to create a docker image of solr that creates a core on startup. Therefore I'm using the docker-entrypoint-initdb.d
extension mechanism described for solr docker containers. The documentation says
The third way of creating a core at startup is to use the image extension mechanism explained in the next section.
But it does not explain exactly how to achieve this.
The Dockerfile I'm using is:
FROM solr:6.6 USER root RUN mkdir /A12Core && 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
The folder A12Core
contains the solr config files for the core. And the script create-a12core.sh
to create the core is:
#!/bin/bash solr-precreate A12Core /A12Core
The /A12Core
dir contains the following files:
./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
However when starting an image build with the above Dockerfile and script an infinite loop seems to be created. The output is:
/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 ...
How do I create a core using the docker-entrypoint-initdb.d
extension mechanism?
1 Answers
Answers 1
Provide precreate-core file location which is to be executed, so edit create-a12core.sh as given below
#!/bin/bash /opt/docker-solr/scripts/precreate-core A12Core /A12Core
Tested and Works !!!
0 comments:
Post a Comment