Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persist Elastic Search Data in Docker Container

I have a working ES docker container running that I run like so

docker run -p 80:9200 -p 9300:9300 --name es-loaded-with-data --privileged=true --restart=always es-loaded-with-data

I loaded up ES with a bunch of test data and wanted to save it in that state so I followed up with

docker commit containerid es-tester
docker save es-tester > es-tester.tar

then when I load it back in the data is all gone... what gives?

docker load < es-tester.tar
like image 931
Casey Johnson Avatar asked Jan 05 '16 20:01

Casey Johnson


1 Answers

If you started from the official ES image, it is using a volume (https://github.com/docker-library/elasticsearch/blob/7d08b8e82fb8ca19745dab75ee32ba5a746ac999/2.1/Dockerfile#L41). Because of this, any data written to that volume will not be committed by Docker. In order to backup the data, you need to copy the data out of the container: docker cp <container name>:/usr/share/elasticsearch/data <dest>

like image 140
creack Avatar answered Sep 29 '22 18:09

creack