17

I have been trying to follow the instructions on https://learning-continuous-deployment.github.io/docker/images/dockerfile/2015/04/22/docker-gui-osx/ about running GUI apps in a docker container inside a MacBookPro host (using Docker tools).

I created a simple docker container using Fedora 23 and with firefox installed.

I try to run firefox and after about a minute I get the following error:

Unable to init server: Broadway display type not supported: 192.168.57.3:0
Error: cannot open display: 192.168.57.3:0

Does anyone have a clue what the error means and/or how to fix it?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
emory
  • 10,725
  • 2
  • 30
  • 58

3 Answers3

24

On a Mac you may find the following steps useful:

  1. Install XQuartz
  2. Open it, goto preferences > Security and check the option to allow connections from network clients
  3. Reboot
  4. Start XQuartz (from the applications folder or with open -a XQuartz)
  5. Allow incoming connections from your ip with xhost + $IP (see note 1)
  6. Run firefox in your docker container (see note 2)

Note 1: Here's a neat trick toget your ip address:

export IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}') 

Note 2: And an example docker run command to start firefox

docker run -it -e DISPLAY=$IP:0 -v /tmp/.X11-unix:/tmp/.X11-unix <image> firefox
Adam Griffiths
  • 1,602
  • 1
  • 13
  • 17
  • Thanks. As far as I can remember this is the procedure I followed. I no longer have a macbookpro and can not verify. – emory Nov 15 '17 at 13:53
  • 4
    Step 3 is important! Logging out and back in is not enough! – trusktr Aug 20 '18 at 19:20
  • This worked brilliantly. Should be the accepted answer – Motin Sep 12 '18 at 12:26
  • Thanks! Works like a charm. Question: why do we have to get the actual address of the net adapter? Why can't we use 127.0.0.1 if all this is happening on a single host? Unrelated: `grep ... | awk ...` is always redundant. You can always add a match clause to awk: `grep abc | awk '$1=="xyz"'` becomes `awk '$0~/abc/ && $1=="xyz"'`. Here though, event that's redundant, since `grep inet` is always true for rows whose first column equals `"inet"`; you can just drop the grep command. – wbadart Dec 04 '18 at 20:28
  • I now am back to using a MacBookPro. I do not know why this solution did not previously work for me, but it does now. So I can personally verify it works. Maybe it works on modern MacBookPros and not on older models. Don't know. – emory Feb 05 '19 at 01:45
2

Rebooting my laptop fixed the problem for me.

David Braun
  • 5,573
  • 3
  • 36
  • 42
  • This worked for me as well. Something to do with XQuartz or xhost right after setting everything up. – Ken J Nov 11 '17 at 03:28
2

I was seeing the same error and unfortunately rebooting did not solve the problem for me. However, I was able to get it working by mounting and pointing to my local .Xauthority file:

IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
docker run --rm  --name firefox -e DISPLAY=$IP:0 -e XAUTHORITY=/.Xauthority --net host -v /tmp/.X11-unix:/tmp/.X11-unix -v ~/.Xauthority:/.Xauthority  jess/firefox

Of course, this assumes your XQuarts/xhost stuff is properly configured according to this answer

dbrianj
  • 440
  • 4
  • 10