Running GUI apps in Docker containers using VNC

In case you don’t feel like reading yet another rant, this is the gist of it:

1) Run your container and expose port 5901 to your host
docker run -p 5901:5901 -t -i ubuntu

2) set up VNC server in the container and run it

sudo apt-get install vnc4server
vnc4server -geometry 1400x1000

3) export $DISPLAY environment variable

export DISPLAY=<change this to the right DISPLAY name from vnc server output, see screenshot below>

4) run your GUI app
5) connect to the VNC server (127.0.0.1:5901) from your host OS using one of the freely available VNC clients.
I used TightVNC and it sure was tight.

That’s it. Now if you feel like reading, I can explain my use case. Read on.
Continue reading “Running GUI apps in Docker containers using VNC”