Open adrifoster opened 4 years ago
Hi, the problem here is that you are using macOS. It doesn't have X11 server by default. But you can install and use XQuartz. Here is nice tutorial how to do it: https://sourabhbajaj.com/blog/2017/02/07/gui-applications-docker-mac/
Let me know if you were succesful with it.
I actually do have XQuartz. I think I fixed it via:
In XQuartz: Check the option: XQuartz -> Preferences -> Security -> "Allow connections from network clients"
Then run in terminal:
IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost + $IP
-e DISPLAY=$IP:0 \
It seems to work now! I am developing my container to give to some end-users who probably aren't really familiar with using the terminal and such, do you know if there is a way to add these DISPLAY and -v commands to the Dockerfile? Sorry I am new to Docker...
You can add -e
(environment variables) to Dockerfile. You can use ENV
for that (check docs). You can't define -v
commands in Dockerfile. Instead of that you can COPY
your files to Dockerfile (check docs).
There is a problem with defining IP address of XQuartz in Dockerfile. If IP address change, you'll have to again use -e
to overwrite it to correct IP address.
I got the same error. I am running the docker on windows 10.
(base) C:\Users\msmsa\Downloads\docker-pyqt5-master>docker run -v /tmp/.X11-unix:/tmp/.X11-unix -v C:/Users/msmsa/Downloads/docker-pyqt5-master/test:/app -e DISPLAY=unix$DISPLAY -u qtuser fadawar/docker-pyqt5 python3 /app/hello.py
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-qtuser'
qt.qpa.screen: QXcbConnection: Could not connect to display unix$DISPLAY
Could not connect to any X display.
and what does the following option do? why do we need it?
-v /tmp/.X11-unix:/tmp/.X11-unix \
and what does the following option do? why do we need it?
-v /tmp/.X11-unix:/tmp/.X11-unix \
It's socket file for X11 server. To use X11 on windows you can check this article: https://cuneyt.aliustaoglu.biz/en/running-gui-applications-in-docker-on-windows-linux-mac-hosts/
Hi,
I am trying to test out this Dockerfile but can't seem to get it to work. I ran the command as you said in your README, but got this error:
I am trying to build this on a Mac running macOS 10.15.5 (Catalina)
Thank you!