The data is getting lost whenever I restart the docker/elk image

I’m using docker/elk image to display my data in kibana dashboard (Version 6.6.0) and It works pretty good. I started the service like using below command.

Command:

    sudo docker-compose up --detach

Expecting that it will run background, and did as expected. After two days the server up and running the and third day the kibana alone getting stopped. and Used below command to make it up and running.

    sudo docker run -d <Docer_image_name>

It’s up and running when I use docker ps command. But when I tried to hit the kibana server in chrome browser it says not reachable.

So I just used to below command to restart the service.

    sudo docker-compose down

After that I can see kibana server in chrome browser which is up and running but I do see all my data is lost.

I used below URL in jenkins to collect the data.

`http://hostname:9200/ecdpipe_builds/extern`al 

Any idea how can I resolve this issue?

Source: StackOverflow