So I've got a Windows 10 machine with VcXsrv running on it. I've got WSL2 on it and in my WSL2 environment I can run my Node.js Puppeteer app in Headful mode without issues.
The issue here is that I now want to run the app inside a Docker container running on WSL2, not in WSL2 directly. I've got a docker container set up and the app works in headless mode, but I've no idea how to configure the Docker container to connect to the X server that is running on the Windows host.
The connection has to go from Docker to WSL2 and then to Windows.
The error puppeteer throws is pretty generic:
(node:92) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
[110:110:0729/163412.032352:ERROR:browser_main_loop.cc(1417)] Unable to open X display.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/var/www/html/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
at ChildProcess.<anonymous> (/var/www/html/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:184:79)
I've got the DISPLAY env variable set up inside the docker container to have the same value as my WSL2 environment does:
workspace@d1d60e8e27a5:/var/www/html$ echo $DISPLAY
172.30.240.1:0.0
This same value works when running the app directly in WSL2