cypress-docker-images icon indicating copy to clipboard operation
cypress-docker-images copied to clipboard

Cypress interactive mode not working in Docker-desktop (Unable to open X Display)

Open HendrikJan opened this issue 1 year ago • 5 comments

Hi,

I used to run the Cypress interactive GUI inside docker like this on Linux:

docker run -it --rm --name cypress \
    --privileged \
    --network host \
    --ipc=host \
    -e DATABASE_URL="mysql://development:[email protected]:8004/test" \
    -e CYPRESS_runType='browser' \
    -e DISPLAY=unix$DISPLAY \
    -e XAUTHORITY=/.Xauthority \
    -v ~/.Xauthority:/.Xauthority:ro \
    -v $PWD:/e2e \
    -w /e2e \
    --entrypoint '' \
    cypress/included:9.7.0 \
    bash -c "cypress open --project /e2e"

This works in plain Docker.

Now I installed Docker Desktop and I get this error:

Unable to open X display.

Docker Desktop creates a container that contains all the other containers, so another layer of container. I can imagine that this is causing the problem, but I don't know how to fix it. As Docker Desktop seems to be the new preferred way to run Docker, and also my colleagues moved over to Docker Desktop, I would like to get Cypress GUI to work on Docker Desktop.

Can I run Cypress in the cypress/included docker container inside Docker Desktop? How?

HendrikJan avatar Oct 10 '22 14:10 HendrikJan

Hi Hendrik, I am also trying to run Cypress GUI from inside Docker Desktop. Do you have X11 server installed? You need to forward the XVFB messages from Cypress out of the Docker container into an X11 server. See this example if you haven't already: (https://www.cypress.io/blog/2019/05/02/run-cypress-with-a-single-docker-command/)

I setup the X11 Server and trying to open Cypress this way(I have a docker-compose.yml file). docker compose run -v /tmp/.X11-unix:/tmp/.X11-unix --rm e2e cypress open.

However, Cypress never opens. (That dri3 extension I get even if I run Cypress headless which that works) image

If I try to pass -e DISPLAY, I get a 'The Test Runner unexpectedly exited via a close event with signal SIGSEGV'

rnunezil avatar Oct 14 '22 20:10 rnunezil

I had a similar problem where Cypress failed to open on Docker Desktop 4.13.0. It opened if I used a local copy but would timeout if I ran it through Docker.

I uninstall Docker Desktop and install Docker Desktop 4.11.0, which appeared to work. I then did the same thing with 4.11.1 and 4.12.0 and they worked too.
Tried 4.13.0 to see if it was broken but it worked.

So, perhaps something broken during the upgrade process?

TLDR: Uninstall and reinstall may fix the issue.

tyler36 avatar Oct 26 '22 01:10 tyler36

Hi @tyler36, thanks for the reply!

Are you saying that interactive mode is now working in Docker for you? On what machine are you working, Linux, Mac or Windows?

HendrikJan avatar Oct 26 '22 06:10 HendrikJan

Yes, I'm on a Win10 with Docker Deskop 4.13.0 running from WSL (Ubuntu 20.04). Test Cypress 10.2.0, 10.8.0, 10.10.0 & 10.11.0

tyler36 avatar Oct 26 '22 06:10 tyler36

I'll try reinstalling then. For me and my colleague, both on Linux, Cypress runs but interactive mode doesn't. At the moment we use a noVNC container to access interactive and that works good enough for the moment.

Anyway thanks 👍

HendrikJan avatar Oct 26 '22 06:10 HendrikJan