I have quickly found out the reason why xvfb-run is failing in my scripts: Execute xvfb-run as docker custom command. However what if I need to run xvfb-run while building an image? (use case here: installing some dependencies in wine / winetricks which require a running X server).
I understand the accepted answer but what if I don't have the liberty to issues docker run --init ? Of course, I can work around it (run Xvfb& and kill it manually afterwards) but using xvfb-run is really nice and clean so I'd like to use that if possible.
The solution was, in retrospect, quite obvious: install
tiniandRUN tini -v -- xvfb-run <parameters>in Dockerfile.