π‘ λ³Έ λ¬Έμλ '[Linux] X11 ν¬μλ©νκΈ° (Ubuntu, MacOS XQuartz): μλ²/λ컀μμ QUI νμΈνκΈ°)'μ λν΄ μ 리ν΄λμ κΈμ λλ€.
Ubuntu μλ²λ docker 컨ν μ΄λμμ GUI νλ‘κ·Έλ¨μ μ€νμν¬ κ²½μ°, X11 forwardingμ ν΅ν΄ ν΄λΉ hostμμ λμΈ μ μλλ‘ μ€μ ν΄μ£Όλ κ³Όμ μ΄ νμνλ° ν΄λΉ λ΄μ©μ λν΄ μ 리νμμΌλ μ°Έκ³ νμκΈ° λ°λλλ€.
1. X11 ν¬μλ©
1.1. X11 ν¬μλ©μ΄λ?
λ³λλ‘ μλ 리λ μ€ PCμ ssh μ μμΌλ‘ μ½μ μμ μ κ°λ₯νλ° GUI νλ‘κ·Έλ¨μ μ€ν ν μκ° μμ΅λλ€. μ΄λ GUI νλ©΄μ ν¬μλ©ν΄μ λ§₯μμ κ·Έ νλ©΄κ³Ό μ‘°μμ κ°λ₯νκ² ν λ €λ©΄ X11 ν¬μλ©μ νλ©΄ λ©λλ€.
μ λ λ©μΈμΌλ‘ macOSλ₯Ό μ¬μ©ν΄μ macOSμμ μ¬μ© ν μ μλ λ°©λ²μ μμ λ³΄κ² μ΅λλ€ . μλ λ§ν¬λ₯Ό μ°Έμ‘° νμμΌλ©° μλ λ§ν¬μμλ macOS λΏλ§μ΄ μλκ³ μλμ°μ 리λ μ€μμ μ¬μ©νλ λ°©λ²λ μμΌλ μ°Έκ³ νμλ©΄ λ©λλ€.
- [blog] How to Set Up and Use X11 Forwarding on Linux and Mac: https://www.businessnewsdaily.com/11035-how-to-use-x11-forwarding.html
1.2. X11 νκ²½ μ€μ
X11 νκ²½ μ€μ (in Window)
VcXsrv Windows X Server Download: https://sourceforge.net/projects/vcxsrv/files/latest/download
X11 νκ²½ μ€μ (in Ubuntu)
$ sudo apt-get update
$ sudo apt-get -y install xorg xrdp xserver-xorg mesa-utils xauth gdm3
$ xhost +local:root
X11 νκ²½ μ€μ (in MacOS)
macOSμμλ XQuartzλΌλ νλ‘κ·Έλ¨μ μ€μΉνλ©΄ λ©λλ€. νλ‘κ·Έλ¨ ννμ΄μ§μμ μ€μΉ νμΌμ λ€μ΄λ‘λ ν μλ μμ§λ§ brewλ₯Ό ν΅ν΄μλ μ€μΉλ₯Ό ν μ μμ΅λλ€.
% brew install --cask xquartz
λ€μ λ‘κ·ΈμΈνκ±°λ μ¬λΆν νλ©΄ Macμμ κΈ°λ³Έ X11 serverλ‘ XQuartxκ° νμ±νλμ΄ X11 ν¬μλ©μ΄ κ°λ₯ν©λλ€. μ΄ν XQuartzμ μ€μ μ μ΄μ΄ Security(보μ) νμμ "Allow connections from network clients(λ€νΈμν¬ ν΄λΌμ΄μΈνΈμμμ μ°κ²°μ νμ©)"λ₯Ό ν΄λ¦νμ¬ ν΄λΌμ΄μΈνΈ μ μμ΄ κ°λ₯νλλ‘ ν©λλ€.
μΆκ°λ‘ xhost μ€μ μ ν΄μ£Όλ©΄ κΈ°λ³Έμ μΈ μ€μ μ΄ λλ©λλ€.
% nano ~/.bashrc
...
xhost + <Server IP>
% source ~/.bashrc
2. X11 ν¬μλ©
2.1. ubuntu μλ² μ μ
2.1.1. Shell μ€ν¬λ¦½νΈ νμ©
sshλ‘ μ μμ -X μ΅μ μ μ£Όλ©΄ X11 ν¬μλ©μ΄ κ°λ₯ν©λλ€.
% ssh -X sjchoi@192.168.0.1
μ΄ν x11-appsμ λ΄μ₯λμ΄ μλ GUI νλ‘κ·Έλ¨(xeyes)μ μ€νν΄ λ³΄λ©΄ μ μμ μΌλ‘ νμκ° λ©λλ€.
sjchoi@sjchoi-desktop$ xeyes
β2.1.2. VSCode νμ©
vscode extensionμμ 'Remote-SSH'λ₯Ό μ€μΉνμ¬ vscodeμμ μ격μΌλ‘ μμ ν μ μλλ‘ λ§λλλ€.
ssh μ€μ κ΄λ¦¬νλ νμΌμΈ ~/.ssh/config λ₯Ό λ€μκ³Ό κ°μ΄ ForwardX11, ForwardX11Trustedλ₯Ό yesλ‘ μΆκ°ν©λλ€.
Host 192.168.0.1
HostName 192.168.0.1
User sjchoi
ForwardX11 yes
ForwardX11Trusted yes
2.2. docker 컨ν μ΄λ μ μ
2.2.1. docker-compose.yml νμ©
μ°Έκ³ : https://github.com/DrawingProcess/ros2-gazebo-docker-arm64
version: "3.8"
services:
ros2:
build:
context: docker/ros2
args:
- user_id=1000
- ros_ws=/home/dockeruser/dev_ws
# Enabling GPU access with Compose
# https://docs.docker.com/compose/gpu-support/
# deploy:
# resources:
# reservations:
# devices:
# - capabilities: [gpu]
# count: all
environment:
# Set a fancy prompt (See ~/.bashrc in the container)
- TERM=xterm-256color
# Mac X11
- DISPLAY=192.168.35.143:0
volumes:
- ./:/home/dockeruser/project
- ./dev_ws:/home/dockeruser/dev_ws
- ./docker/ros2/.ros:/home/dockeruser/.ros
- ./docker/ros2/.gazebo/:/home/dockeruser/.gazebo
# Mac X11
- /tmp/.X11-unix:/tmp/.X11-unix
- ~/.Xauthority:/root/.Xauthority:rw
privileged: true
μ¬κΈ°μ μ€μν κ²μ DISPLAY νκ²½λ³μ μ€μ μ μμ΄μ νλ©΄μ λμ°κ³ μ νλ '<Host OS IP>:0'μ λ£μ΄μ£Όμ΄μΌ νλ€λ μ μ΄λ©°, hostμ κ²½μ° μμμ μΈκΈν xhost + <Server IP>λ‘ νΉμ μλ²μ λν μ κ·Όμ νμ©ν΄μΌ ν©λλ€. μΆκ°λ‘ ':0'μ μλ―Έλ λμ€νλ μ΄ ν¬νΈλ₯Ό μλ―Έν©λλ€.
μ΄ν ν΄λΉ docker-compose.yml λ₯Ό λ°νμΌλ‘ μ΄λ―Έμ§λ₯Ό λ§λ€μ΄ ν΄λΉ 컨ν μ΄λλ₯Ό λμμ€λλ€.
% docker-compose build
% docker-compose up -d
% docker-compose exec --user root ros2 bash
μ΄ν ν΄λΉ 컨ν μ΄λ λ΄λΆμμ x11-apps ν¨ν€μ§ λ΄λΆμ μλ xclockμ μ€νμν€λ©΄ μκ³κ° λ¨λ κ²μ νμΈν μ μμ΅λλ€.
$ xclock
μ°Έκ³
- [blog] How to Set Up and Use X11 Forwarding on Linux and Mac: https://www.businessnewsdaily.com/11035-how-to-use-x11-forwarding.html
- [Official]XQuartz: https://www.xquartz.org/index.html
- [Github] X11 forwarding on macOS and docker: https://gist.github.com/sorny/969fe55d85c9b0035b0109a31cbcb088
- [StackOverFlow] X11 forwarding of a GUI app running in docker: https://stackoverflow.com/questions/44429394/x11-forwarding-of-a-gui-app-running-in-docker
- [Blog] X11 ν¬μλ© νκΈ° (macOS): https://blog.naver.com/PostView.naver?blogId=chcbaram&logNo=222920381690&categoryNo=0&parentCategoryNo=0&viewDate=¤tPage=1&postListTopCurrentPage=1&from=postView
- [Blog] How to install X Window System XQuartz on macOS for ssh X11 forwarding: https://www.cyberciti.biz/faq/apple-osx-mountain-lion-mavericks-install-xquartz-server/