bubblewrap icon indicating copy to clipboard operation
bubblewrap copied to clipboard

File binding lost if DEST deleted and recreated

Open garywill opened this issue 5 years ago • 2 comments

I want the app in container always see DEST same as my SRC

bwrap --dev-bind / /  --ro-bind   SRC DEST  in-container-app

Some programs outside container delete DEST and create a new one. Then the file binding loses effect. Also happends to --bind-data.

Is there a solution?

garywill avatar May 15 '20 04:05 garywill

This is how Unix directories work. bwrap binds SRC into the container, but rm -fr SRC will delete all the files from SRC; the bind-mount points to the same directory object in the kernel, so this has the effect of deleting all those files from DEST inside the container. (SRC will disappear from its parent directory, but will not actually be removed from disk until the programs that can see DEST have all exited.) bwrap cannot avoid this.

There is no solution other than either copying SRC recursively and binding the copy, or implementing cooperative locking so that programs outside the container will not delete a SRC that is in use. Flatpak uses a lock file ${directory}/.ref for its apps and runtimes.

smcv avatar May 15 '20 09:05 smcv

Some programs outside container delete DEST and create a new one.

If you can make them delete DEST’s contents and not DEST itself, that’s usually a good fix.

charmander avatar May 16 '20 02:05 charmander