Mount Single File

Hello,

Is there anything against mounting a single file from the host to a container? Let’s say:

$ lxc config device add CT1 nginx-conf disk source=/mnt/NVME1/data/nginx.conf path=/etc/nginx/nginx.conf

It seems to work fine, I can view the file on the container and whatnot, but can I break something or is it safe?

Thank you.

I believe it would be less “error prone” if you use incus/lxd file pull and file push to manage files inside one or more containers.

In your example scenario, not mounting the file from the host ensures the nginx service inside containers to operate continuously even if something interferes with the host /mnt/NVME1/data/nginx.conf file (like deleting it or changing its content to an invalid one).

Just my 2c.

It will work fine, the main catch though is that most editors don’t actually modify a file, instead they modify a copy and then delete+rename.

This means that if you now edit the file, either in the container or on the host, the change will not be reflected as the mount will remain tied to the old copy of the file.

2 Likes

Thank you once again. That was the kind of small details I was looking for before running into trouble.

1 Like