Tricks with Containers and Small VMs¶
- Author:
Dimitry Dukhovny
Behold the silly container tricks.
Run GUI Software on Your Headless UNIX Box¶
1# For RHEL-like, e.g. Oracle Linux, Centos, or Fedora
2yum -y install x11vnc xvfb
3# For Debian-like, e.g. Ubuntu, Raspbian, or Devuan
4apt-get install x11vnc xvfb
5
6# Create a credential path for the user you want. Yes, even root (you idiot).
7mkdir ~/.vnc; chmod 700 ~/.vnc
8x11vnc -storepasswd ~/.vnc/passwd # This will prompt for a password
9
10# Start the VNC server
11x11vnc -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¶
1FROM ubuntu:18.04
2RUN apt-get update
3RUN apt-get install -y x11vnc xvfb firefox
4RUN mkdir ~/.vnc
5RUN chmod 700 ~/.vnc
6# Notice the password in plain text. This is bad-ish.
7RUN x11vnc -storepasswd VNCPASSWORD ~/.vnc/passwd
Fetch a Docker image and start the container
1docker build . 2>&1 | tee /tmp/docker-build.out
2# Given no problems...
3docker image tag `grep "Successfully built" /tmp/docker-build.out | awk '{print $NF}'` ubuntu/vnc
4docker 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.