본문 바로가기

Study/linux

docker에서 컨테이너 gui 실행하기

 

우분투의 그래픽은 시스템이 아니다. 프로그램이다.

그래서 리눅스 서버버전을 실행하면 gui가 없던 것!!

 

출처: https://medium.com/@SaravSun/running-gui-applications-inside-docker-containers-83d65c0db110

우분투는 `Xorg`라는 그래픽 프로그램을 이용한다. 즉, 얘가 있어야 그래픽을 띄워줄 수 있다는 얘기.

그럼 도커에서 그래픽을 띄워주려면? 호스트의 자원을 공유하면 된다. 호스트의 Xorg를 컨테이너가 이용하면 된다는 말.

실행옵션을 추가해주면 컨테이너에서도 그래픽을 볼 수 있다.

 

도커를 gui로 실행하는 방법은 두 가지가 있다. 1. VNC를 이용하거나 2. 단순히 XServer를 공유하거나.

VNC를 이용하는 방법은 여기여기를 참고하자. Xauthority 어쩌구저쩌구한다.

 

...더보기

Xauthority becomes an issue with newer systems. I can either discard any protection with xhost + before running my docker containers, or I can pass in a well prepared Xauthority file. Typical Xauthority files are hostname specific. With docker, each container can have a different host name (set with docker run -h), but even setting the hostname of the container identical to the host system did not help in my case. xeyes (I like this example) simply would ignore the magic cookie and pass no credentials to the server. Hence we get an error message 'No protocol specified Cannot open display'

The Xauthority file can be written in a way so that the hostname does not matter. We need to set the Authentication Family to 'FamilyWild'. I am not sure, if xauth has a proper command line for this, so here is an example that combines xauth and sed to do that. We need to change the first 16 bits of the nlist output. The value of FamilyWild is 65535 or 0xffff.

 

Xserver를 공유하는 방법이 더 간편하다.

 

 

 

XServer 공유하기

host의 XServer를 볼륨형태로 컨테이너와 공유하자. DISPLAY 환경 변수도 전달해줘야 한다.

유닉스 도메인 소켓을 이용하여 host의 XServer와 도커 컨테이너를 연결한다.  readonly옵션을 준다.

XServer소켓은 `/tmp/.X11-unix`에 존재한다.

 

1
2
--volume /tmp/.X11-unix:/tmp/.X11-unix:ro
-e DISPLAY=unix$DISPLAY

 

 

호스트에서 도커가 xserver와 통신할 수 있도록 설정한다. 다른 터미널을 열고 작업한다.

1
$ xhost +local:docker

 

 

이제 GUI로 도커 이미지를 실행할 수 있다.

 

 

 

참고:

 

 

[Running GUI Application inside Docker Containers]

 

Running GUI Applications inside Docker Containers

While the IT world is embracing Containers Technology primarily for Enterprise Server Applications, There is also a huge scope of Docker…

medium.com

http://wiki.ros.org/docker/Tutorials/GUI

 

docker/Tutorials/GUI - ROS Wiki

Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. Using GUI's with Docker Description: This tuto

wiki.ros.org

 

[우분투 xorg]

 

Xorg/Guide/ko - Gentoo Wiki

Xorg는 사용자의 손 끝에 그래픽 환경을 전달해주는 X 윈도 서버en입니다. 이 설명서에서는 Xorg가 무엇인지, 어떻게 설치하는지, 어떤 다양한 설정 옵션이 있는지 설명하겠습니다. X 서버가 무엇인가요? 그래픽환경 vs 커맨드환경 일반 사용자는 커맨드라인 인터페이스(CLI)에서 명령을 타이핑해야한다는 생각에 놀랄지도 모릅니다. 왜 젠투가 (그리고 일반적인 리눅스가) 제공하는 자유를 통해서 마우스 커서로 가리키고 클릭하는 것이 가능하지 않을까요? 물론

wiki.gentoo.org

[Docker에서 GUI프로그램을 돌려야 할 때]

불러오는 중입니다...

[Linux컨테이너에서 GUI애플리케이션 실행하기]

 

Docker - Linux 컨테이너에서 GUI 애플리케이션 실행하기 | docker Tutorial

docker documentation: Linux 컨테이너에서 GUI 애플리케이션 실행하기

riptutorial.com

[what is tmp x-11 unix]

 

What is `/tmp/.X11-unix/`?

I asked Google the same question and didn't like the results I got. What is /tmp/.X11-unix/?

unix.stackexchange.com

 

 

 

[Xhost 문서]

 

Xhost (한국어) - ArchWiki

요약 출처: Xhost man 문서 xhost는 호스트 이름이나 사용자 이름을 X 서버에 접속이 허용된 목록에 추가하거나 삭제하는 프로그램이다. 호스트의 경우, 개인 정보를 통제하고 보호하는 기본 틀을 제공한다. 최악의 남용을 제한할지라도, 워크스테이션 환경(단독 사용자)에서만 충분할 뿐이다. 더욱 정교한 제어가 필요한 환경에서는 사용자 기반 메커니즘을 구현하거나 X 서버에 다른 인증 자료를 전달하는 프로토콜의 hook을 사용해야 한다. man xhost

wiki.archlinux.org

[리눅스X11 포워딩]

 

리눅스 X11 포워딩(X11 Forwarding) - ssh 접속으로 GUI 프로그램 실행하기

원격에 있는 리눅스 장비(서버)에 ssh 접속해서 GUI 기반의 어플리케이션을 실행하기 위한 방법이다. 예를 들어 서버에 접속해서 해당 서버에 설치되어 있는 웹브라우저를 실행하면 웹브라우저 실행창이 클라이언트쪽에 표시되도록 하는 것이다.X윈도우(X-Windows, X11) 기반의 기능이므로, 서버와 클라이언트 양쪽 다 X윈도우 기반이어야 한다는 점에 유의하

bahndal.egloos.com

 

 

얘는 그냥 신기해서 : http://blog.naver.com/PostView.nhn?blogId=occidere&logNo=221133121595&categoryNo=21&parentCategoryNo=0&viewDate=&currentPage=1&postListTopCurrentPage=1&from=postView

 

10. ssh와 xhost를 통해 원격으로 GUI를 사용해 보자.

일반적으로 원격으로 작업하는 경우, 주로 터미널을 통한 TUI 작업을 하였다. 그러나, 그래프 확인 등의...

blog.naver.com

http://blog.topmania.com/?p=1026

 

xhost 명령과 display옵션 사용하기 – xhost,oracle,display옵션 | TopMania Blog

xhost 명령과 display옵션 사용하기 – xhost,oracle,display옵션 출처: http://blog.empas.com/rarravis/121240?v=trackback&l=1 리눅스를 사용하는 분들중에 xhost 명령을 제대로 사용하지 못하는 사람들이 몇몇 있어서 한번 적어본다. 얼마전에 만났던 Oracle 엔지니어도 이걸 못해서… 오라클 설치하면서 oracle 계정으로 로그인을 해서 설치하는 꼴을 봤다. 얼마나 없어보이던지… ^^ 두

blog.topmania.com