Rationale: One of my apps have multiple volumes but Fly currently does not allow multiple volumes in one container. A concrete example is here: NodeBB/Dockerfile at caf8722fd55d48255e58bb695228b2edbfc13508 · NodeBB/NodeBB · GitHub.
In Kubernetes we can specify the subpath for the volume.
volumeMounts:
- mountPath: /var/lib/mysql
name: site-data
subPath: mysql
- mountPath: /var/log/mysql
name: site-data
subPath: log
This will bind <volume path of site-data>/mysql
to /var/lib/mysql
and <volume path of site-data>/log
to /var/log/mysql
, so we can share the volume storage. In Fly it should be:
[[mounts]]
source = "site-data"
sub_path = "mysql"
destination = "/var/lib/mysql"
[[mounts]]
source = "site-data"
sub_path = "log"
destination = "/var/log/mysql"
This is usually implemented with a bind mount, so there are also workarounds inside Fly Machine (just do bind mounts yourself every time before launching the entrypoint).
Current workaround for example:
fly.toml
[mounts]
source = "site-data"
destination = "/data"
Inside SSH or your own entrypoint script:
$ flyctl ssh console
$ mount --bind /data/mysql /var/lib/mysql
$ mount --bind /data/log /var/log/mysql