I am trying to run any GUI container I can on MacOS. With every container I try (firefox, chrome, tor, spotify, etc) I always get the error Error: cannot open display
. And it's not specific to the docker run
command where I pass the environment flag with my $DISPLAY
. When I try to run xhost +
I get the same error.
I have a fresh XQuartz installation. It is up and running. I have turned on "allow connections from network" under security. I've tried building my own images and pulling jessie frazelle's images. I do not suspect it is a docker issue or the Dockerfiles. It is something on the host, my laptop. I can't seem to figure out what it is.
MacOS Sierra 10.12.5
Docker 17.12.0 Stable
XQuartz 2.7.11 (xorg-server 1.18.4)
My local's $DISPLAY
is set to :0.0
DISPLAY is correctly setup by ssh. My DISPLAY generally looks like localhost:10.0 or some similar 10, 11, 12, ... display number. This is the local end of an ssh tunnel back to my Mac. When you changed your DISPLAY environment variable, you totally bypassed all the work ssh did to make displaying X11 windows on your Mac easy.
Use -Y. From the man page on ssh: -Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls. If you're still having problems though, you can try setting $DISPLAY to your local box's IP: People seem to have this problem commonly when ssh'ing from Mac OS X. You may also want to set
Or are you using the DISPLAY environment variable established by ssh via the -X or -Y options. In my previous reply, it looked to me you were doing good right up until you change DISPLAY and then tried using xhost . I just *ssh -X* into my Linux box and that is all I need to do. DISPLAY is correctly setup by ssh.
It seems thing got somehow reset to certain defaults with the 10.5.6 and/or 10.5.7 for Xorg and/or Apple's X11 somehow. There are for both options available and one of them is "nolisten_tcp".
So I finally got this to work. And it seems it was pretty simple. I am not certain how this actually fixes the issue, but now the containers work.
How I fixed it was opening up XQuartz and then opening up the "Terminal" app from the "Applications" menu. Then running the command export DISPLAY=192.168.1.X:0
, then xhost +
. It outputted something like this "access control disabled, clients can connect from any host". After that I was able to run my docker run
commands to launch the desired GUI containers.
I am still uncertain how this works and not running them from my laptops Terminal app, but it worked. It must be something I have set in my local env. Hopefully this helps someone else out who may be running into the same issues.
Based on @Byron's answer, I've found out that I could get it to work by running these 2 commands in the normal terminal:
export DISPLAY=:0
/opt/X11/bin/xhost +
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With