How to migrate a database (ElasticSearch) inside a container

Hello,

I’m new to Docker and I’m currently working for a company that uses Docker to manage our development platform.

We’re using an ElasticSearch image, version 2.4, and we want to upgrade it to ElasticSearch 5.4.

Of course I know I can docker-compose down, modify the docker-compose.yml file, and docker-compose up, but what about the data which is in a volume?

What’s the proper way to migrate a database inside a Docker container?