Am I able to make it so that If I connect a single-file docker volume to a container, and the application makes an attempt to move or remove the file, the system allows it, rather than returning "Permission denied." or "...is a directory."?
e.g.
docker run -it \
-v $(PWD)/config:/tmp/buildroot/.config \
rootbuilder \
make menuconfig
When the make menuconfig
attempts to save the .config
file, what it is actually doing is:
- Storing it in a temporarily file
- Deleting the existing
.config
file (unlink) - Moving the temporary file into place (move)
Because mounting files in docker is using a tmpfs mount, unlinking or moving it is like attempting to perform that operation on a mount - which makes no sense.
To solve this problem, I could:
- mount the directory as a volume, but that would mean having to store the rest of the application in the volume so it would not be a clean environment every time; or
- put the config into a subdirectory and convince the application to find the config there - which is messy; or
- copy the config into place before running the application, and then pipe the result back into the original file - but this would mean also detecting if that file existed, and would get steadily more complex the more files are involved
Is there a better way to solve the problem of a single-file needing to be moved/removed when mounted through a docker volume?