Xvfb & Docker - unable to open screen

I need to run XVFB and docker with firefox, but I can not get them to work together

Here is my Docker file:

FROM abevoelker/ruby:latest # based on ubuntu ENV TERM linux RUN apt-get update && apt-get install -y ..... ENV DISPLAY :99 # Install Xvfb init script ADD xvfb_init /etc/init.d/xvfb # default xvfb init.d RUN chmod a+x /etc/init.d/xvfb CMD ["firefox"] 

The error message I get from Firefox is

  Error: cannot open display: :99 
+5
source share
1 answer

I solved this by writing a startup script that would: - run xvfb - start firefox

By invoking it with the RUN command, xvfb starts when the container starts.

Dockerfile

 ... ENV DISPLAY :99 ADD run.sh /run.sh RUN chmod a+x /run.sh CMD /run.sh 

run.sh

 Xvfb :99 -screen 0 640x480x8 -nolisten tcp & firefox 
+5
source

All Articles