How to add an elasticsearch index during docker build

前端 未结 3 822
无人共我
无人共我 2020-12-08 14:01

I use the official elasticsearch docker image and wonder how can I include also during building a custom index, so that the index is already there when I start the container

3条回答
  •  情书的邮戳
    2020-12-08 14:32

    The simple way of doing this could be using below Dockerfile.

    Run this Dockerfile with docker build -t elasticsearch-custom:latest .

    FROM elasticsearch:5.5.1 AS esbuilder
    ADD script.sh path/to/insert/script.sh
    RUN apt-get update \
        && apt-get install procps -y \
        && apt-get install httping -y \
        && /docker-entrypoint.sh elasticsearch -d -E path.data=/tmp/data \
        && while ! httping -qc1 http://localhost:9200 ; do sleep 1 ; done \
        && path/to/insert/script.sh \
        && apt-get clean
    
    FROM elasticsearch:5.5.1
    COPY --from=esbuilder /tmp/data/ /usr/share/elasticsearch/data/
    

    And then just run docker run -t -d elasticsearch-custom:latest

提交回复
热议问题