Feature Request: Volume Subpath

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
3 Likes

Thanks for sharing your use case AND your current approach to it, I’m used to just symlink sometimes, never thought of mount-ing it.

As for Fly.io we also happened to stumble on a similar use case, for GitHub - fly-apps/postgres-flex: Postgres HA setup using repmgr we just mounted things directly on /data but I agree that this could be more seamless.

Fun fact: we are working on a k8s offering on Fly too.

Added volumes, wishlist

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