In order to run Xorg apps on macOS you will need to install xquartz:
brew install --cask --no-quarantine xquartzAnd then configure it
defaults write org.xquartz.X11 nolisten_tcp -bool false
defaults write org.xquartz.X11 no_auth -bool false
defaults write org.xquartz.X11 enable_iglx -bool true
mkdir -p ~/.xinitrc.d
cat << 'EOF' > ~/.xinitrc.d/xhost-config.sh
#!/bin/sh
xhost +127.0.0.1
xhost +localhost
xhost +\$(hostname)
EOF
chmod +x ~/.xinitrc.d/xhost-config.sh
open -a XQuartzNo need to restart anything or log in/out.
You can then run Xorg apps easily:
docker run -e DISPLAY=docker.for.mac.host.internal:0 petedavidson887/xclock:0.0.1Note that you will still need to explicitly provide the DISPLAY env variable every time you run a Docker container. As far as I know there is no way to set a default env variable for all containers — at least not on Docker for macOS.
Run the following, then restart XQuartz:
defaults write org.xquartz.X11 enable_render_extension -bool falseIf the misbehaving app is a Java app you can try adding the following option to your docker run command:
-e JAVA_TOOL_OPTIONS='-Dsun.java2d.xrender=false -Dsun.java2d.pmoffscreen=false -Dremote.x11.workaround=false -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine -Djava2d.font.loadFontConf=true'(source)
If you have the following error: libGL error: failed to load driver: swrast then you can attempt to add this argument to your docker run command:
-e LIBGL_ALWAYS_INDIRECT=1