$ brew install socat
$ brew cask install xquartz <--- assuming you don't already have XQuartz installed some other way
$ open -a XQuartz <--- start an XQuartz session
$ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
In a new terminal:
$ inconfig
Look for the IP address assigned to your Docker VM; the interface will be something like vboxnet0
or vboxnet1
$ docker run --rm -e DISPLAY=[IP address of vboxnet0]:0 [image] [command]
For example, to run the Arduino IDE, I've used
$ docker run --rm -e DISPLAY=192.168.99.1:0 davechick/arduino-dev arduino
See moby/moby#8710 for more info
Fixed!