I have a YAML file for distrobuilder that sets up MariaDB in an image. Now, I need to attach a volume to the container at /var/lib/mysql, but I’ve run into an issue.
I don’t want the volume to overwrite any existing data in the container. For example, Docker has a way to avoid this behavior, as described in Docker’s documentation.
I haven’t found anything like this in the distrobuilder or Incus documentation. Is there a flag or feature that prevents a volume from being mounted over existing data? Or is this something that might be implemented in future versions?
As far as I am aware there isn’t such a feature in Incus, might be worth to create a feature ticket for it. From my understanding of the provided link you can perform the same steps manually.
create a new storage volume in incus
attach that volume to your container under /tmp/volume
copy or move all data from /var/lib/mysql to /tmp/volume
reattach the volume to /var/lib/mysql
start your container
This is the only way you can recreate the pointed out Docker feature. Think having similar functionality in Incus would be a great addition.
@stgraber — do you think adding a feature like Docker’s volume mounting behavior would make sense for Incus? Manual copying doesn’t really scale with many containers.
I had a look at issue #1822, but it seems to focus on tmpfs support rather than on preserving existing container data when mounting a new volume.
Would it make sense to open a separate feature request specifically for that behavior?