2017-06-26 33 views
0

我試圖用預加載的數據構建elasticsearch圖像。我正在從S3進行恢復操作。Elasticsearch docker在圖像中刻錄數據

FROM elasticsearch:5.3.1 

ARG bucket 
ARG access_key 
ARG secret_key 
ARG repository 
ARG snapshot 

ENV ES_JAVA_OPTS="-Des.path.conf=/etc/elasticsearch" 

RUN elasticsearch-plugin install repository-s3 

ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/e1f115e4ca285c3c24e847c4dd4be955e0ed51c2/wait-for-it.sh wait-for-it.sh 

RUN chmod +x wait-for-it.sh 

RUN /docker-entrypoint.sh elasticsearch -p /tmp/epid & ./wait-for-it.sh -t 0 localhost:9200 -- echo "Elasticsearch is ready!" && \ 
curl -H 'Content-Type: application/json' -X PUT "localhost:9200/_snapshot/$repository" -d '{ "type": "s3", "settings": { "bucket": "'$bucket'", "access_key": "'$access_key'", "secret_key": "'$secret_key'" } }' && \ 
curl -H "Content-Type: application/json" -X POST "localhost:9200/_snapshot/$repository/$snapshot/_restore?wait_for_completion=true" -d '{ "indices": "myindex", "ignore_unavailable": true, "index_settings": { "index.number_of_replicas": 0 }, "ignore_index_settings": [ "index.refresh_interval" ] }' && \ 
curl -H "Content-Type: application/json" -X GET "localhost:9200/_cat/indices" 

RUN kill $(cat /tmp/epid) && wait $(cat /tmp/epid); exit 0; 

CMD ["-E", "network.host=0.0.0.0", "-E", "discovery.zen.minimum_master_nodes=1"] 

圖像構建成功,但是當我啓動容器索引丟失。我沒有使用任何卷。我錯過了什麼?

version: '2' 

services: 
    elasticsearch: 
    container_name: "elasticsearch" 
    build: 
     context: ./elasticsearch/ 
     args: 
     access_key: access_key_here 
     secret_key: secret_key_here 
     bucket: bucket_here 
     repository: repository_here 
     snapshot: snapshot_here 
    ports: 
     - "9200:9200" 
     - "9300:9300" 
    environment: 
     ES_JAVA_OPTS: "-Xms1g -Xmx1g -Des.path.conf=/etc/elasticsearch" 

回答

0

似乎卷不能在圖像中燒燬。保存生成數據的目錄由父映像指定爲卷。唯一的方法是分叉父Dockerfile並刪除卷部分。