- How Fly Volumes work
- How to manage volumes with flyctl commands
- How to manage volume snapshots (backups)
Launch a new app with a Fly Volume
Use Fly Launch to create a new app with one Machine and an attached volume, and then clone the Machine to scale out.-
Launch a new app from your project source directory with the
--no-deployoption so it doesn’t deploy automatically. Include any required options for deploying your app, like--imageor--dockerfile.fly launchcreates afly.tomlapp configuration file in your project source directory. -
After the app is created, add a
[mounts]section in thefly.toml, wheresourceis the volume name anddestinationis the directory where the volume should be mounted on the Machine file system. For example:Note: You can’t mount a volume withdestination="/"since/is used for the root file system. -
Deploy the app:
- Confirm that the volume is attached to a Machine.
-
(Recommended only if your app handles replication) Clone the first Machine to scale out to two Machines with volumes:
List volumes to check the result:Example output showing two volumes with attached Machines:
Add volumes to an existing app
Add a volume to an app created with Fly Launch.-
Add a
[mounts]section in the app’sfly.toml, wheresourceis the volume name anddestinationis the directory where the volume should be mounted on the Machine file system. For example: -
Run
fly statusto check the regions of the Machines and then create the volume in the same regions as your app’s Machines. For example: -
Repeat step 2 for each Machine in the process group. If you create an app using the
fly launchcommand, then the app will usually have two Machines in theappprocess by default.Note: If you have multiple Machines, then you need to create an equal number of volumes with the same name. For example, your app’s[mounts]config specifiessource="myapp_data"and you have three Machines inbos(Boston), then you need to create three volumes namedmyapp_datainbos. Every volume has a unique ID to allow for multiple volumes with the same name. -
Deploy the app:
- Confirm that the volume is attached to a Machine.
Confirm the volume is attached to a Machine
Use flyctl to check the status of volumes and Machines.List the Machines
List Machines to check attached volumes:List the volumes
List volumes to check attached Machines:SSH into the Machine
View the volume in the Machine file system:/data:
destination field in the [mounts] section of the fly.toml file, or the attach-volume option for cloned Machines.
Access a volume
Access and write to a volume on a Machine just like a regular directory. For Machines managed with Fly Launch, thedestination under [mounts] in fly.toml is the path for the mounted volumes.
For unmanaged Machines, you specify the mount path when you add a volume to a cloned Machine or create a Machine and attach a volume.
Related topics
- Fly Volumes overview
mountssection in thefly.tomlapp configuration file- Create and manage volumes
- Manage volume snapshots
- Scale an app with volumes