Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX X11 Error cannot open display

Tags:

docker

macos

x11

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

like image 709
Byron Mansfield Avatar asked Jan 19 '18 06:01

Byron Mansfield


People also ask

How do I setup display on my Mac?

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.

How do I enable X11 forwarding on a Mac?

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

How do I setup display in Linux?

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.

Is there a nolisten_TCP option for the X11?

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".


2 Answers

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.

like image 160
Byron Mansfield Avatar answered Oct 23 '22 07:10

Byron Mansfield


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 +
like image 12
Lucas Pottersky Avatar answered Oct 23 '22 06:10

Lucas Pottersky