# Initialize an ElasticSearch Docker container with predefined indices

**URL:** <https://discuss.elastic.co/t/initialize-an-elasticsearch-docker-container-with-predefined-indices/310482>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [July 24, 2022, 2:33pm UTC](https://discuss.elastic.co/t/initialize-an-elasticsearch-docker-container-with-predefined-indices/310482 "2022-07-24T14:33:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ido\_Gada](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ido_gada/32/103499_2.png) [@Ido\_Gada](https://discuss.elastic.co/u/Ido_Gada)\
**Post date:** [July 24, 2022, 2:33pm UTC](https://discuss.elastic.co/t/initialize-an-elasticsearch-docker-container-with-predefined-indices/310482/1 "2022-07-24T14:33:09Z")

</div>

Hello,

We are using the official Docker images for ElasticSearch, and for development purposes, we would like the single node cluster to initialize with predefined indices. Is this possible?  
The same way were you put SQL script in a certain location in the MYSQL image, it gets executed.

We can export the mapping via http:\<ES\_HOST\>/\<index\_name\>/\_mapping  
And use that in the body of a curl command as mentioned here

> **[Create index API | Elasticsearch Guide \[8.3\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html)**

Thank you

---

<div class="post-metadata">

**Author:** ![Ido\_Gada](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ido_gada/32/103499_2.png) [@Ido\_Gada](https://discuss.elastic.co/u/Ido_Gada)\
**Post date:** [July 25, 2022, 2:59pm UTC](https://discuss.elastic.co/t/initialize-an-elasticsearch-docker-container-with-predefined-indices/310482/2 "2022-07-25T14:59:59Z")

</div>

Does anyone have an idea how to approach this issue?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 25, 2022, 3:41pm UTC](https://discuss.elastic.co/t/initialize-an-elasticsearch-docker-container-with-predefined-indices/310482/3 "2022-07-25T15:41:01Z")

</div>

There is nothing built in as far as I know. One way would be to attach a snapshot repository and restore the indices from there. This would however require a number of API calls once the node is up and running.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 22, 2022, 3:41pm UTC](https://discuss.elastic.co/t/initialize-an-elasticsearch-docker-container-with-predefined-indices/310482/4 "2022-08-22T15:41:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
