Volumes
Learn how to attach, change and detach volumes on your service
Volumes preserve files between deployments. Without a volume, everything your service writes to disk is lost whenever the container is replaced, for example on every deploy or restart. Database files, uploads or SQLite files should live inside a volume.
Volumes belong to a server, not to a service. See server volumes to manage volumes and backups.
Attach a Volume
Click Attach a Volume, select a volume on the server, and enter the container folder to mount it at.
Use Create new Volume in the dropdown to create one, then enter its name and mount path.
Attaching a volume redeploys your service.
Choosing the Mount Path
The mount path is the absolute path of the folder inside your container that gets stored in the volume.
- It must start with a
/, for example/dataor/app/uploads - It may only contain letters, numbers,
.,_,-and/. Spaces are not allowed - Each mount path can only be used once per service
Use an absolute path from the container root, including your application's working directory where applicable. If your Dockerfile sets WORKDIR /app and your app writes to ./uploads, the mount path is /app/uploads.
Most images document the folder where they store their data. Some common examples:
| Image | Mount path |
|---|---|
| PostgreSQL | /var/lib/postgresql/data |
| MySQL | /var/lib/mysql |
| Redis | /data |
| MongoDB | /data/db |
Anything your app writes outside of the mount path is lost on the next deploy.
If you attach an empty volume to a folder that already contains files in your image, Docker copies these files into the volume on the first start. After that, the volume content takes precedence.
Sharing Volumes Between Services
Multiple services on the same server can share a volume, each at its own mount path. A volume can only be attached to services on the server it was created on, and only once per service.
If several services write to the same files at the same time, data can get corrupted. Never let two running databases share a data folder.
Change the Mount Path
Select the volume and click Update below its mount path, or choose Edit Volume from the three dot menu. Enter the new mount path and save.
Your service is redeployed. The data inside the volume stays untouched and is available at the new path. If the volume is shared, only the mount path of the current service changes.
Make sure your app expects its data at the new path before you switch. Otherwise it starts with an empty state.
Detach a Volume
Select the volume and click Detach. Your service is redeployed without it. The volume and its data remain on the server until you delete it.
Backups
Volumes are backed up daily. See volume backups for manual backups and restores.
Suspended Services
Volumes can't be attached, detached or changed while a service is suspended, for example because of unpaid invoices. The data inside the volume stays on the server.
How is this guide?