I am trying to run selenium in docker. first I found a docker image from blueimp.
FROM blueimp/geckodriver
USER root
RUN apt-get update
RUN apt-get install -y --fix-missing x11-utils wget xclip firefox-esr xvfb xsel unzip libncurses5 libxslt-dev libxml2-dev libz-dev npm nodejs
RUN wget -q "https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz" -O /tmp/geckodriver.tgz \
&& tar zxf /tmp/geckodriver.tgz -C /usr/bin/ \
&& rm /tmp/geckodriver.tgz
RUN ln -s /usr/bin/geckodriver \
&& chmod 777 /usr/bin/geckodriver \
RUN /usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 & export DISPLAY=":99"
RUN curl -L https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz > geckodriver-v0.24.0-linux64.tar.gz && tar -xzf geckodriver-v0.24.0-linux64.tar.gz && rm geckodriver-v0.24.0-linux64.tar.gz && mv geckodriver /usr/local/bin && chmod -R 777 /usr/local/bin
COPY package.json /src/package.json
RUN cd /src; npm install
COPY . /src
CMD ["node", "/src/app.js"]
this docker file works fine and builds complete successfully. without xvfb selenium complains with this error: invalid argument: can't kill an exited process .
then according to this answer : https://stackoverflow.com/a/53198328/5677187 you can handle selenuim with some virtual display. but when I try to run my docker container it comes with this error:
xvfb-run : xvfb failed to start
I am entring to running container shell and execute this: Xvfb and the output is :
fatal server error:
(EE) Server is already active for display 0 . if this server is no longer running, remove /tmp/.X0-lock