I am trying to dockerise a small python application. The python code uses the PyQt4 library. The app has some test units which I run when I build the image. Something like the following:
RUN [ "/bin/bash", "-c", "source activate conda_environment && python -m unittest tests/tests_html_consistency.py" ]
The PyQt4 library in the python code needs a X server to do its things, but docker do not have one, therefore, unfortunately when I build the image I get the following error:
python -m unittest: cannot connect to X server
On other similar stack questions I found that a possible solution would be to simply mount the socket for the X server as a Docker volume and tell Docker to use that instead.
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY TheImage
But how do I do this at image build time? The above command works only when the image is already build, at 'docker run' time. Moreover, if the host machine is an aws instance (hence without x server) would that work? I don't think so...