"I'm not proud of being a congenital pain in the ass. But I will take money for it."

Further adventures with VNC and X11

Sat 07 September 2019 | -- (permalink)

A previous article mentioned strange games running Xvfb inside a Docker container. Today we have a few strange games using VNC and X11.


Sometimes you need to run something dangerous in a web browser, or need to run a web browser somewhere you're not. An example of the first might be a dodgy AJAX interface to some remote service. An example of the latter might be needing to use an HTML5-based upload mechanism via an interface which takes a server down for the duration of the upload, and you're at the wrong end of a bad consumer grade network connection, so you really want to stage the upload to a better-connected server before pushing the button.

If you already have Docker infrastructure, one way to solve this would be to stuff Firefox and Xvnc into a container, which you can then get to pop up on your desktop via a VNC client. Forget about micro-services, this thing is a pig, but hey, it works.

Here's a proof of concept. Season to taste, and remember that you almost certainly want to tunnel VNC through ssh rather than running raw VNC on the network. But it also works just fine locally, so you can spin up a burner Firefox on your laptop and talk to it via VNC on the loopback interface.


Say you just got a Raspberry Pi 4 and want to use it to control a display or projector, but don't want to leave a keyboard and trackball connected to it. No worries. x11vnc is an X11 client that mirrors both the display and they input devices out through a VNC connection, so you can just ssh into your Pi 4, tunneling VNC as suggested in the documentation, and control your Pi 4 from your VNC viewer.

This isn't restricted to a Raspberry Pi, of course, you can use it with a desktop Linux or *BSD machine. In theory you could even use it to tunnel into a Docker container running Xvfb but if there's a sane application for that I haven't thought of it yet.