Introduction
An alternative for virtual machine is a Docker container.
Containers are usually running without GUI.
To get GUI one can utilize the famous and well-designed x11docker project.
It already has pre-configured container with MATE desktop, which is based on Debian Buster. And what is interesting - such image has 10K+ downloads and is most popular variant.
Below is the method of using x11docker
to run Ubuntu MATE.
Quick start
To run Ubuntu MATE with x11docker one should follow the following steps:
-
Install Docker and dependencies to the host system
sudo apt-get update sudo apt-get install docker.io git xserver-xephyr
-
Add current user to the
docker
groupsudo usermod -a -G docker $USER
then reboot machine.
-
Prepare folder for Docker repository
mkdir ~/Docker cd ~/Docker git clone https://github.com/N0rbert/dockerfile-x11docker-ubuntu-mate.git cd dockerfile-x11docker-ubuntu-mate wget https://raw.githubusercontent.com/mviereck/x11docker/master/x11docker chmod +x x11docker sudo mv x11docker /usr/local/bin/x11docker
-
Build default Ubuntu MATE 20.04 LTS image locally
docker build ~/Docker/dockerfile-x11docker-ubuntu-mate -t ubuntu-mate:focal
-
Run Docker container with Ubuntu MATE
-
minimal, using default settings
x11docker --desktop ubuntu-mate:focal
-
more functional, using extra options
x11docker --desktop ubuntu-mate:focal --sudouser --dbus --share ~/Public --clipboard --pulseaudio --xtest --init=systemd
where options are the following:
-
--sudouser
– allows running commands withsudo
and password isx11docker
; -
--dbus
– DBUS session bus for desktop and other applications; -
--share ~/Public
– share folder between host system and container; -
--clipboard
– share clipboard; -
--pulseaudio
– share audio; -
--xtest
– use XTest X11 extension (needed for Onboard); -
--init=systemd
– use systemd as init system inside container.Other options are available in
x11docker --help
output.
The result will look like shown below:
-
One can run almost any preinstalled application in the opened graphical MATE session or install any other by using APT.
-
Advanced usage
Advanced usage allows one to build and run any supported Ubuntu MATE version inside Docker container with X11.
To build the container use:
-
Ubuntu 18.04 LTS (bionic)
export VER=bionic; docker build --build-arg "VER=$VER" ~/Docker/dockerfile-x11docker-ubuntu-mate -t ubuntu-mate:$VER
-
Ubuntu 20.04 LTS (focal, default)
export VER=focal; docker build --build-arg "VER=$VER" ~/Docker/dockerfile-x11docker-ubuntu-mate -t ubuntu-mate:$VER
-
Ubuntu 20.10 (groovy)
export VER=groovy; docker build --build-arg "VER=$VER" ~/Docker/dockerfile-x11docker-ubuntu-mate -t ubuntu-mate:$VER
-
upcoming Ubuntu 21.04 (hirsute)
export VER=hirsute; docker build --build-arg "VER=$VER" ~/Docker/dockerfile-x11docker-ubuntu-mate -t ubuntu-mate:$VER
To run the container from the same terminal use:
x11docker --desktop ubuntu-mate:$VER --sudouser --dbus --share ~/Public --clipboard --pulseaudio --xtest --init=systemd
or explicitly specify needed version by replacing $VER
variable with actual version as shown below:
x11docker --desktop ubuntu-mate:groovy --sudouser --dbus --share ~/Public --clipboard --pulseaudio --xtest --init=systemd
Notes about legacy versions
For some purposes one may need to run Ubuntu MATE versions like 12.04 LTS, 14.04 LTS and 16.04 LTS inside Docker container without systemd
.
Building and run commands are below:
-
Ubuntu 12.04 LTS (precise)
export VER=precise; docker build --build-arg "VER=$VER" ~/Docker/dockerfile-x11docker-ubuntu-mate -t ubuntu-mate:$VER x11docker --desktop ubuntu-mate:precise --sudouser --dbus --share ~/Public --clipboard --pulseaudio --xtest --runasroot 'chmod 0440 /etc/sudoers'
-
Ubuntu 14.04 LTS (trusty)
export VER=trusty; docker build --build-arg "VER=$VER" ~/Docker/dockerfile-x11docker-ubuntu-mate -t ubuntu-mate:$VER x11docker --desktop ubuntu-mate:trusty --sudouser --dbus --share ~/Public --clipboard --pulseaudio --xtest
-
Ubuntu 16.04 LTS (xenial)
export VER=xenial; docker build --build-arg "VER=$VER" ~/Docker/dockerfile-x11docker-ubuntu-mate -t ubuntu-mate:$VER x11docker --desktop ubuntu-mate:xenial --sudouser --dbus --share ~/Public --clipboard --pulseaudio --xtest
Above will give one opportunity to learn the history of Ubuntu MATE.
Conclusion
This gives almost unlimited possibilities for experiments.
But remember, that container is reseted on every launch, only data in shared folder stays saved.
Notes and limitations:
- MATE Screensaver is removed from all images.
- Both Snap and FlatPak currently do not work in the containers.
- Ubuntu MATE 12.04 LTS, 14.04 LTS and 16.04 LTS do not use
systemd
in the container. - Ubuntu MATE 18.04 LTS and 20.04 LTS do not have any workaround applied in the Dockerfile.
- Ubuntu MATE 20.10 have the following workarounds: to avoid systemd lock-up
acpid
,acpi-support
andsssd-common
packages are removed; - Upcoming Ubuntu MATE 21.04 have the following workarounds: to avoid systemd lock-up
acpid
andacpi-support
packages are removed, theredshift-gtk
package is removed as not functional.