Persist data from container to host

I am running docker on windows 10 laptop, I’ve set up my first container running Elasticsearch using a Dockerfile and it works. Every time I stop the container and start it again the data is gone.

On my windows machine I created a folder in location C:/Docker/esdata and in my elasticsearch.yml i’ve added path.data: /usr/share/elasticsearch/data is were data is. In the Dockerfile I added:

VOLUME /c/Docker/esdata:/usr/share/elasticsearch/data

but this still doesn’t work, can someone tell me what i’m doing wrong.

Have you gone into the Docker settings, clicked on “Shared Drives” and made sure that the C drive is available to your containers by clicking on the “Shared” checkbox for C ?