pgh
pgh

Reputation: 213

How to run GUI application from linux container in Window using Docker?

I have a QT based GUI application which i compiled in docker (centos image). I am able to launch GUI application from inside Centos image in my Linux machine(OpenSUSE 13.2) Following instruction from this blog "http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker"

Same thing i want to do via window.I installed window docker . I loaded the desired centos images having my GUI application and and through terminal trying to launch GUI by using container . It gives Error saying" gui: cannot connect to X server"

Any idea or solution .

Upvotes: 5

Views: 4720

Answers (3)

SebastianH
SebastianH

Reputation: 786

This solution based on a blog article from Robin Kretzschmar. I tested it with the following Dockerfile.

FROM ubuntu:22.10
RUN apt-get update 
RUN apt-get install -y kate
CMD kate

The container is build with

docker build . -t test/kate

On your Windows Host you need to install a x-server, I used VcSrv. After you started VcSrv, you can run

docker run -ti --rm -e DISPLAY=host.docker.internal:0.0 test/kate

and an instance of kate is shown

Upvotes: 0

pgh
pgh

Reputation: 213

I started vncserver and then can see my application with vncviewer .

Upvotes: 2

VonC
VonC

Reputation: 1324278

There was a similar discussion on docker issue 8710, but for MacOS:

A somewhat crude way to do this:

Start socat to expose local xquartz socket on a TCP port

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

(Note: for Windows, you would need at least:

Pass the display to container (assuming virtualbox host is available on 192.168.59.3):

 docker run -e DISPLAY=192.168.59.3:0 jess/geary

(This is insecure on public networks, add bind, su and range options to socat to limit access.)

Upvotes: 3

Related Questions