Running a Docker Container with GUI on Mac OS
-
Install XQuartz
brew install xquartz
-
Run XQuartz
open -a XQuartz
-
Allow Network Connections (XQuartz/Preferences)
- Authenticate connections
- Allow connections from network clients
-
Get the Host IP
IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
-
SET DISPLAY Environment Variable
export DISPLAY=$IP:0
-
Add Path to “xhost” to my zsh-Profile; added this line to .zshrc:
export PATH=/usr/X11/bin/xhost:$PATH
-
Added the IP with xhost
xhost + $IP
-
Run ROS Noetic from Docker Container (test)
docker pull osrf/ros:noetic-desktop-full docker run -dit --platform linux/amd64 -e DISPLAY=$IP:0 -v /tmp/.X11-unix:/tmp --name ros osrf/ros:noetic-desktop-full
-
Open ~/.bashrc and add the following lines
source /opt/ros/noetic/setup.bash