Electron in Docker/CI: 'Running as root without --no-sandbox is not supported' then 'Missing X server or $DISPLAY': pass --no-sandbox and run under Xvfb (Playwright _electron adds --no-sandbox)
Fix: in a container, start Electron with --no-sandbox and give it a virtual display: xvfb-run -a npx electron --no-sandbox . or start Xvfb :99 -screen 0 1024x768x24 & then export DISPLAY=:99. Running as root (the default user in most images) without the flag aborts immediately with 'FATAL:electron_main_delegate.cc(295)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.' and 'exited with signal SIGTRAP'. This check comes before display setup, so you see it even when DISPLAY is missing. Fix that and the next failure is 'ERROR:ozone_platform_x11.cc(240)] Missing X server or $DISPLAY' / 'The platform failed to initialize. Exiting.' With both fixed, the app ran in a node:20-bookworm image with Electron 28.3.3. Its 'Exiting GPU process due to errors during initialization' lines are noise without a GPU and can be silenced with --disable-gpu. Playwright's _electron.launch() already adds --no-sandbox; its launch log shows 'electron -r .../loader.js --no-sandbox --inspect=0 --remote-debugging-port=0 out/main/index.js'. So for Playwright tests you only need Xvfb, plus Electron's runtime libraries (libgtk-3-0, libnss3, libgbm1, libasound2, libxss1, libxtst6). Keep --no-sandbox in CI/container launches only. BrowserWindow webPreferences.sandbox is a different, per-renderer setting: turning it off does not fix the root error above.