I am trying to run a test with headed mode on ubuntu with GUI on docker container.
I have created an image that's creating a docker image with GUI + VNC so i will able to watch it.
Dockerfile:
# Pull base image.
FROM ubuntu
RUN apt-get update
# Install LXDE and VNC server.
RUN apt-get install -y xvfb
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y lxde-core lxterminal tightvncserver
RUN apt-get install -y xfce4
RUN rm -rf /var/lib/apt/lists/*
RUN touch /root/.Xresources
COPY xstartup /root/.vnc/xstartup
RUN chmod +x /root/.vnc/xstartup
# Define working directory.
WORKDIR /data
COPY * /data
# Install Playwright dependencies
RUN npm install
# # # Install dependencies.
RUN npx @playwright/test install
# Expose ports.
EXPOSE 5901
I am initiating this container using this command:
docker run -it --rm -v /data:/data -p 5901:5901 -e USER=root ubuntudsktp bash -c "vncserver :1 -geometry 1280x800 -depth 24 && tail -F /root/.vnc/*.log"
I am able to log in to the container through VNC successfully, but when I am trying to execute some tests by using this command:
xvfb-run npx playwright test test.spec.js --headed
I can see the test is executed successfully but the browser is not opening in the VNC session.
What am I missing here? How can make the test open the browser?