I'm looking at setting up Elasticsearch within Docker and am trying to figure out the best method for inserting new data. Currently, after running
docker-compose up, I run a series of curl commands to set up the index and bulk import data:
curl -XDELETE http://localhost:9200/my_index curl -XPUT http://localhost:9200/my_index -H 'Content-Type: application/json' -d@/index.json curl -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@/bulk_import.json" curl -XPOST 'localhost:9200/my_index/_refresh'
This works fine, but I have to run these commands every time I restart the container (because the index and data are gone with it). I'm definitely missing something hopefully obvious, so would love if someone could point me in the right direction here.
docker-compose.yml if it helps:
version: '3' services: es: image: docker.elastic.co/elasticsearch/elasticsearch:7.1.1 container_name: es environment: - discovery.type=single-node ports: - 9200:9200 - 9300:9300 volumes: - esdata1:/usr/share/elasticsearch/data volumes: esdata1: driver: local