I'm trying to run 2 cypress docker container in parallel using node js spawn
docker run -v path/to/ws:/e2e -w /e2e --network host cypress/included:8.0.0 --spec 'cypress/integration/cytorus-cache/1.feature'
docker run -v path/to/ws:/e2e -w /e2e --network host cypress/included:8.0.0 --spec 'cypress/integration/cytorus-cache/2.feature'
It fails with following error;
Xvfb exited with a non zero exit code.
There was a problem spawning Xvfb.
This is likely a problem with your system, permissions, or installation of Xvfb.
----------
Error: _XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
So basically, if I run 4 parallel processes, 1 of them connects to X11 server and 3 gets error.
How it can be handlled? I've already tried setting unset DISPLAY
as Cypress runs in headless mode by default. But it didn't help.
As per cypress docker documentation,
When running on Linux, Cypress needs an X11 server; otherwise it spawns its own X11 server during the test run. When running several Cypress instances in parallel, the spawning of multiple X11 servers at once can cause problems for some of them. In this case, you can separately start a single X11 server and pass the server's address to each Cypress instance using DISPLAY variable.
Since the X11 server was already running on the server, I just spawned Xvfb :99 &
, then set the address export DISPLAY=:99
. And passed the DISPLAY environment variable to the docker cypress container.