This script allows you to clean up elastic search indexes older than a specified number of days. Install it on the desired machine and hang up the task in cron to run it daily. Then it will automatically work and you can forget about outdated indexes.
Replace the following variable values with yours in the dockerfile and try to assemble the container. You can always get the log that the docker container gives and find out if something went wrong.