Attaching a Fly.io (cloud) volume to ElasticSearch Dockerfile to maintain persistent storage.

I’m trying to deploy my elasticsearch docker container on fly.io cloud service. As i have understood till now is that first of all:

  1. Fly.io doesn’t allow working with docker-compose files making it harder to work with.
  2. You can only work with Dockerfiles when deploying to the service.

So i am deploying my Elasticsearch container to the same but i want to maintain persistent storage so that the data doesn’t get lost when the container is restarted.

For maintaining persistent storage, Fly offers ‘volumes’ to attach to Docker container. And the data in the elasticsearch container which will be used for persistant storage will be at location:

‘/usr/share/elasticsearch/data’. I want to know how can i attach the volumes to the Dockerfile so that the data will remain persistant and will be accessible when the container restarts.

To attach a volume, you should define a [mounts] section in your fly.toml. Here’s a guide: Add Volume Storage · Fly Docs

Hey thanks for your reply. But how will it be connected to the data folder in the running elasticsearch container? do i have to mention that in the destination? like this:

[mounts]
  source="esdata01"
  destination="/usr/share/elasticsearch/data"

source is the name of volume i created?

Yup, that looks right to me

Nice but do i need to add anything in the Dockerfile also… i mean do i have to specify anything about the volume??

Nope, nothing in the Dockerfile. Just make sure that elasticsearch is configured to put its data in /usr/share/elasticsearch/data

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.