I'm trying to open Firefox GUI on a Docker container.
I'm avoiding most common solution which seems to use at one point /tmp/.X11-unix
from host because I want the container to work on any host, including a headless host without X11.
The goal is just to use selenium to open Firefox GUI and take a screenshot.
I'm not quite sure if it possible but I guess it is.
FROM ubuntu:latest
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y update
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install python3 python3-pip firefox-geckodriver x11vnc xvfb
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install x11-xserver-utils
RUN DEBIAN_FRONTEND="noninteractive" pip install --upgrade --no-cache-dir pip-with-requires-python && \
pip install --upgrade --no-cache-dir --prefer-binary selenium
WORKDIR /app
COPY entrypoint.sh .
COPY script.py .
RUN chmod +x entrypoint.sh
CMD ["x11vnc", "-create", "-forever"]
ENV DISPLAY :0
CMD ["xhost", "+"]
ENTRYPOINT ["/app/entrypoint.sh"]
Currently xhost ouput xhost: unable to open display :0
. I'm not sure about the :0
but I tried several values.
Selenium of course also fails with:
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0
I'm running out of ideas so anything would be appreciated :)
I'm probably missing an important part.