Wine in Docker - "reg add" only keeps effects temporarily
Solution 1:
I've been trying to persist a wine registry change in Docker too, and I found through experimentation that in my environment it takes between 1 and 2 seconds for the registry file (~/.wine/user.reg
) to be modified after invoking wine reg add
.
There is a related query here. Hopefully there is a way to synchronously flush the registry to disk; otherwise the easiest thing might be to loop until the file is modified.
Here is how I did it in one situation (this registry change enables the "Show dot files" option):
RUN before=$(stat -c '%Y' /home/xclient/.wine/user.reg) \
&& wine reg add 'HKEY_CURRENT_USER\Software\Wine' /v ShowDotFiles /d Y \
&& while [ $(stat -c '%Y' /home/xclient/.wine/user.reg) = $before ]; do sleep 1; done
This is probably safe because it's a single change to the default registry (which is not very large: only 16KB apparently), but all sorts of things could go wrong in more complex situations:
- If you make multiple modifications to the registry, they may not all be flushed to disk at the same time, so looking at the file modification date would be insufficient
- It might be possible to exit the loop while the file is still being written to disk, so you would end up with a corrupt registry file