如何使用docker-solrs图像扩展机制创建solr核心?

Spa*_*ker 8 solr docker dockerfile

我想创建一个solr的docker镜像,在启动时创建一个核心.因此,我正在使用为solr docker容器描述的docker-entrypoint-initdb.d扩展机制.文件说

在启动时创建核心的第三种方法是使用下一节中介绍的图像扩展机制.

但它并没有解释如何实现这一目标.

我正在使用的Dockerfile是:

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
Run Code Online (Sandbox Code Playgroud)

该文件夹A12Core包含核心的solr配置文件.create-a12core.sh创建核心的脚本是:

#!/bin/bash

solr-precreate A12Core /A12Core
Run Code Online (Sandbox Code Playgroud)

/A12Core目录包含以下文件:

./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
Run Code Online (Sandbox Code Playgroud)

但是,当使用上面的Dockerfile和脚本启动图像构建时,似乎会创建一个无限循环.输出是:

/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
...
Run Code Online (Sandbox Code Playgroud)

如何使用docker-entrypoint-initdb.d扩展机制创建核心?

Pre*_*rem 8

提供要执行的 precreate-core 文件位置,因此编辑 create-a12core.sh 如下所示

 #!/bin/bash
 /opt/docker-solr/scripts/precreate-core  A12Core /A12Core
Run Code Online (Sandbox Code Playgroud)

经测试有效!!!

  • 抱歉,我不是故意让赏金过期的。一旦系统允许,我已经开始了一个新的奖励给你。 (6认同)