Run GUI application in MacOS 10 in Docker
문제
I'd like to run an application in a Docker container that can start a GUI. This guide recommends using XQuartz. After starting XQuartz, run the following:
ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost + $ip
docker run -d --name firefox -e DISPLAY=$ip:0 -v /tmp/.X11-unix:/tmp/.X11-unix jess/firefox
This gives your local device permission to access the host server. Running the above, I get the error:
cannot connect to X server 10.0.0.69:0
해결책
I was not using the right display number. The guide above uses the default display number :0
.
Find the correct one by running:
display_number=`ps -ef | grep "Xquartz :\d" | grep -v xinit | awk '{ print $9; }'`
Then change your docker run command to include the flags:
-e DISPLAY=$ip:$display_number \
-v /tmp/.X11-unix:/tmp/.X11-unix \
제휴하지 않습니다 apple.stackexchange