Skip to content

GUI applications

Kostas Mavrommatis edited this page Feb 7, 2018 · 2 revisions

Based on information gathered from the internet (https://github.com/JAremko/docker-x11-bridge, https://xpra.org/)

There are multiple ways to run a gui application using docker.

The following notes are using the docker-x11-bridge which has the following features

  • is fully containerized, i.e. can be deployed to either an RCE site shell server, an AWS instance, or on the laptop
  • creates persistent sessions, i.e. one can disconnect from the application and reconnect without losing the session
  • applications can be accessed either by a web browser interface or an Xpra client directly

Run the GUI application and access it through a browser

Get the x11-bridge docker image

Pull the image from DockerHub

docker pull jare/x11-bridge

Run a new container which will host the x-server

docker run -d \
 --name x11-bridge \
 -e MODE="tcp" \
 -e XPRA_HTML="yes" \
 -e DISPLAY=:14 \
 -e XPRA_PASSWORD=111 \
 -p 10000:10000 \
 jare/x11-bridge

Replace the password '111' with whatever value you want

Make a note of the name that you have assigned to this container (in this example 'x11-bridge' and the port that this listens to (in this example 10000).

Get the GUI application of interest and bind it to the x11-bridge

docker run -d \
 --name emacs-1 \
 --volumes-from x11-bridge \
 -e DISPLAY=:14 \
 jare/emacs emacs

Note the arguments --volumes-from that take the value 'x11-bridge' which is the name we gave to the server container, and the value DISPLAY which is the same for both containers.

Now get the ip of the computer you run the x11-bridge container e.g. type ifconfig and look for the IP

Now you can access the GUI container by connecting your browser to the address http://<IP>:10000/index.html?encoding=png&password=<PASSWORD>

You will get a browser window with the application running in it.

If needed a second container can start with the same command arguments (--volume-from, -e) which will appear as a second 'window' within the browser window.

Run the GUI application and access it through an xpra client

what is Xpra?

xpra is similar to an Xclient/Xserver couple but it allows the X applicatio running when the client disconnects (in a way it is similar to running "screen" or "tmux" for an X application. To connect to a new or running Xpra session you need to have an xpra client. For more information visit http://xpra.org

Get the x11-bridge docker image

Pull the image from DockerHub

docker pull jare/x11-bridge

Run a new container which will host the x-server

ddocker run -d \
 --name x11-bridge \
 -e MODE="ssh" \
 -p 22:22 \
 -v ~/.ssh/pub_rsa:/etc/pub-keys/me.pub \
 -e DISPLAY=:14 \
 jare/x11-bridge

Replace the public key file location with whatever value you want

Make a note of the name that you have assigned to this container (in this example 'x11-bridge').

Get the GUI application of interest and bind it to the x11-bridge

docker run -d \
 --name emacs-1 \
 --volumes-from x11-bridge \
 -e DISPLAY=:14 \
 jare/emacs emacs

Note the arguments --volumes-from that take the value 'x11-bridge' which is the name we gave to the server container, and the value DISPLAY which is the same for both containers.

Now get the ip of the computer you run the x11-bridge container e.g. type ifconfig and look for the IP

xpra attach --encoding=rgb --ssh="ssh -o StrictHostKeyChecking=no -p 22" ssh:xpra@localhost:14

You will get a new window with the application running in it.

If needed a second container can start with the same command arguments (--volume-from, -e) which will appear as a second 'window' within the browser window.