#################################### Tricks with Containers and Small VMs #################################### :Author: Dimitry Dukhovny .. contents:: Behold the silly container tricks. Run GUI Software on Your Headless UNIX Box ========================================== .. code-block:: bash :linenos: :caption: Install x11vnc and xvfb # For RHEL-like, e.g. Oracle Linux, Centos, or Fedora yum -y install x11vnc xvfb # For Debian-like, e.g. Ubuntu, Raspbian, or Devuan apt-get install x11vnc xvfb # Create a credential path for the user you want. Yes, even root (you idiot). mkdir ~/.vnc; chmod 700 ~/.vnc x11vnc -storepasswd ~/.vnc/passwd # This will prompt for a password # Start the VNC server x11vnc -forever -usepw -create Then, connect to to your VM or container using VNC on port 5900. Start a Docker container with an X GUI and nothing else ------------------------------------------------------- .. code-block:: docker :linenos: :caption: Dockerfile FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y x11vnc xvfb firefox RUN mkdir ~/.vnc RUN chmod 700 ~/.vnc # Notice the password in plain text. This is bad-ish. RUN x11vnc -storepasswd VNCPASSWORD ~/.vnc/passwd Fetch a Docker image and start the container .. code-block:: bash :linenos: docker build . 2>&1 | tee /tmp/docker-build.out # Given no problems... docker image tag `grep "Successfully built" /tmp/docker-build.out | awk '{print $NF}'` ubuntu/vnc docker run -p 6900:5900 -e HOME=/root/ ubuntu/vnc x11vnc -forever -usepw -create Every time you stop this Docker image and restart it, all user settings will flush. This makes for a great operational browsing window.