In some cases, you don't want to setup a complicated Linux Desktop environment on your local machine, with virtualization or dual-boot. You can use Docker to run a Linux Desktop environment in a container. This is a simple way to try out Linux Desktop environment without installing it on your local machine.

You can use Docker to run a Linux Desktop environment in a container. This is a simple way to try out Linux Desktop environment without installing it on your local machine.

Step Simplified

file

sudo docker run -p 10000:3389 hub.aiursoft.cn/aiursoft/internalimages/remote-desktop

Step 1 - Install Docker

No matter what host OS you are using, (Support Windows, Linux, MacOS), you need to have Docker installed on your local machine obviously.

You can follow the instructions on the official Docker website.

Step 2.A - Pull my built image from Docker Hub

I have built a Docker image with the Linux Desktop environment. You can pull it from Docker Hub.

docker pull hub.aiursoft.cn/aiursoft/internalimages/remote-desktop:latest

Then you can run the container with the following command:

docker run -d -p 33900:3389 --name remote-desktop hub.aiursoft.cn/aiursoft/internalimages/remote-desktop:latest

Now, you can use a Remote Desktop client to connect to localhost:33900 to access the Linux Desktop environment.

Step 2.B - Build the image yourself

If you want to build the image yourself, you can write a new Dockerfile with the following content:

FROM hub.aiursoft.cn/aiursoft/internalimages/ubuntu:latest
EXPOSE 3389/tcp
ARG USER=test
ARG PASS=1234
ARG X11Forwarding=false

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC

# Install tzdata and set the timezone to UTC
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
    apt-get install -y tzdata && \
    echo "Etc/UTC" > /etc/timezone && \
    ln -fs /usr/share/zoneinfo/UTC /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata

RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
    apt-get install -y dbus-x11 xrdp sudo openssl gnome-shell ubuntu-desktop-minimal gnome-console && \
    [ $X11Forwarding = 'true' ] && apt-get install -y openssh-server; \
    apt-get autoremove --purge; \
    apt-get clean;

# Remove the reboot required file
RUN rm /run/reboot-required* || true

# Create a user and add it to the sudo group
RUN useradd -s /bin/bash -m $USER -p $(openssl passwd "$PASS"); \
    usermod -aG sudo $USER; \
    adduser xrdp ssl-cert;

# Setting the required environment variables
RUN echo 'LANG=en_US.UTF-8' >> /etc/default/locale; \
    echo 'export GNOME_SHELL_SESSION_MODE=ubuntu' > /home/$USER/.xsessionrc; \
    echo 'export XDG_CURRENT_DESKTOP=ubuntu:GNOME' >> /home/$USER/.xsessionrc; \
    echo 'export XDG_SESSION_TYPE=x11' >> /home/$USER/.xsessionrc;

# Enabling log to the stdout
RUN sed -i "s/#EnableConsole=false/EnableConsole=true/g" /etc/xrdp/xrdp.ini;

# Disabling system animations and reducing the image quality to improve the performance
RUN sed -i 's/max_bpp=32/max_bpp=16/g' /etc/xrdp/xrdp.ini; \
    gsettings set org.gnome.desktop.interface enable-animations true;

# Listening on wildcard address for X forwarding
RUN [ $X11Forwarding = 'true' ] && \
        sed -i 's/#X11UseLocalhost yes/X11UseLocalhost no/g' /etc/ssh/sshd_config || :;

# Adding the user to the sudoers file
RUN echo "$USER ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers.d/$USER

CMD rm -f /var/run/xrdp/xrdp*.pid >/dev/null 2>&1; \
    service dbus restart >/dev/null 2>&1; \
    /usr/lib/systemd/systemd-logind >/dev/null 2>&1 & \
    [ -f /usr/sbin/sshd ] && /usr/sbin/sshd; \
    xrdp-sesman --config /etc/xrdp/sesman.ini; \
    xrdp --nodaemon --config /etc/xrdp/xrdp.ini

Then you can build the image with the following command:

file

docker build -t remote-desktop .

And run the container with the following command:

docker run -d -p 33900:3389 --name remote-desktop remote-desktop

Step 3 - Connect to the Linux Desktop environment

Now, you can use a Remote Desktop client to connect to localhost:33900 to access the Linux Desktop environment.

You can use the following credentials to login:

  • Username: test
  • Password: 1234

Enjoy your Linux Desktop environment in a Docker container!

file

You can install a browser now. With command:

wget https://dl-ssl.google.com/linux/linux_signing_key.pub -O /tmp/google.pub
sudo gpg --no-default-keyring --keyring /etc/apt/keyrings/google-chrome.gpg --import /tmp/google.pub
echo 'deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt update
sudo apt install -y google-chrome-stable

file

Package usage

gdm3

GDM3, also known as GNOME Display Manager 3, is the default login manager for the GNOME desktop environment. It is an X Window System service that manages user logins and logouts. GDM3 is part of GNOME 3, and it is the successor to GDM of GNOME 2.

gdm3's dependencies are very basic, including dbus, systemd, libpam, libglib, etc. Only installing GDM will not install the GNOME desktop environment. The only change is that the login interface becomes the GNOME login interface.

Dependencies are as follows:

accountsservice (>= 0.6.35), adduser, bash (>= 4.3), dconf-cli (>= 0.20), dconf-gsettings-backend (>= 0.20), dbus-bin | systemd-sysv, dbus-daemon, default-dbus-system-bus | dbus-system-bus, default-logind | logind, gir1.2-gdm-1.0 (= 42.0-1ubuntu6), ubuntu-session | gnome-session | x-session-manager | x-window-manager | x-terminal-emulator, gnome-session-bin (>= 3.37.0), gnome-session-common (>= 3.37.0-2~), gnome-settings-daemon (>= 3.37.0), gnome-shell (>= 3.37.90), gsettings-desktop-schemas, libgdm1 (= 42.0-1ubuntu6), libglib2.0-bin (>= 2.35.0), libpam-modules (>= 0.72-1), libpam-runtime (>= 0.76-13.1), librsvg2-common, lsb-base (>= 3.2-14), policykit-1 (>= 0.105-5~), procps, ucf, x11-common (>= 1:7.6+11), x11-xserver-utils, debconf (>= 0.5) | debconf-2.0, libaccountsservice0 (>= 0.6.55), libaudit1 (>= 1:2.2.1), libc6 (>= 2.34), libcanberra-gtk3-0 (>= 0.25), libcanberra0 (>= 0.2), libgdk-pixbuf-2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.68.0), libgtk-3-0 (>= 3.0.0), libgudev-1.0-0 (>= 232), libkeyutils1 (>= 1.5.9), libpam0g (>= 0.99.7.1), libselinux1 (>= 3.1~), libsystemd0, libx11-6, libxau6 (>= 1:1.0.9), libxcb1, libxdmcp6

gnome-shell

Gnome Shell is one of the core components of the GNOME desktop environment. It is a desktop environment for Linux and other Unix-like systems. Gnome Shell is a new user interface for GNOME 3, and it is the successor to the GNOME Panel of GNOME 2.

Gnome Shell depends on gdm3, gnome-session, gnome-settings-daemon, gsettings-desktop-schemas, etc. After installing Gnome Shell, you can use the GNOME desktop environment.

Attention: By default, deploying Gnome-Shell does not install any terminal programs. If you install Gnome-Shell directly and restart, you may find yourself in a dilemma where you cannot open a terminal. It is recommended to install a terminal program, such as gnome-console, before installing Gnome-Shell.

file

Dependencies are as follows:

evolution-data-server (>= 3.33.1), gir1.2-accountsservice-1.0, gir1.2-adw-1, gir1.2-atk-1.0, gir1.2-atspi-2.0 (>= 2.36), gir1.2-gcr-3 (>= 3.7.5), gir1.2-gdesktopenums-3.0 (>= 3.12), gir1.2-gdkpixbuf-2.0, gir1.2-gdm-1.0 (>= 3.18.2), gir1.2-geoclue-2.0, gir1.2-glib-2.0 (>= 1.56.0), gir1.2-gnomebluetooth-3.0 (>= 3.12.0), gir1.2-gnomedesktop-3.0 (>= 3.35.90), gir1.2-graphene-1.0 (>= 1.10.2), gir1.2-gstreamer-1.0, gir1.2-gtk-3.0 (>= 3.16), gir1.2-gtk-4.0, gir1.2-gweather-3.0 (>= 40.0), gir1.2-freedesktop, gir1.2-ibus-1.0 (>= 1.5.22-2ubuntu2~), gir1.2-mutter-10 (>= 42.0), gir1.2-nm-1.0, gir1.2-nma-1.0, gir1.2-pango-1.0, gir1.2-polkit-1.0, gir1.2-rsvg-2.0, gir1.2-soup-2.4 (>= 2.40.1), gir1.2-upowerglib-1.0 (>= 0.99), gir1.2-webkit2-4.0 (>= 2.16.0), gnome-settings-daemon (>= 40~), gnome-shell-common (= 42.0-2ubuntu1), gsettings-desktop-schemas (>= 42~beta), gstreamer1.0-pipewire (>= 0.3.10), libglib2.0-bin (>= 2.53.0), python3, ubuntu-wallpapers, dconf-gsettings-backend | gsettings-backend, libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 1.12.4), libc6 (>= 2.34), libcairo2 (>= 1.14.0), libecal-2.0-1 (>= 3.33.4), libedataserver-1.2-26 (>= 3.33.1), libgcr-base-3-1 (>= 3.8.0), libgdk-pixbuf-2.0-0 (>= 2.23.0), libgirepository-1.0-1 (>= 1.35.9), libgjs0g (>= 1.71.1), libgles2, libglib2.0-0 (>= 2.67.3), libgnome-autoar-0-0 (>= 0.1.1), libgnome-desktop-3-19 (>= 3.35.90), libgraphene-1.0-0 (>= 1.5.4), libgtk-3-0 (>= 3.21.6), libgtk-4-1 (>= 4.0.0), libical3 (>= 3.0.0), libjson-glib-1.0-0 (>= 1.5.2), libmutter-10-0 (>= 42.0), libnm0 (>= 1.10.4), libpango-1.0-0 (>= 1.37.5), libpangocairo-1.0-0 (>= 1.14.0), libpolkit-agent-1-0 (>= 0.100), libpolkit-gobject-1-0 (>= 0.94), libpulse-mainloop-glib0 (>= 13), libpulse0 (>= 13), libsecret-1-0 (>= 0.7), libsystemd0, libwayland-server0 (>= 1.0.2), libx11-6, libxfixes3

It is interesting that there are Ubuntu wallpapers in the dependencies.

gnome-core

Gnome COre is a set of core applications for GNOME desktop environment. If you only installed gnome-shell and gdm3, you can use GNOME desktop environment. You don't need to install gnome-core.

Ubuntu does not install gnome-core, but installs ubuntu-desktop.

Gnome Core depends on many things, including gnome-shell, gnome-session, gnome-settings-daemon, gsettings-desktop-schemas, etc. Dependencies are as follows:

adwaita-icon-theme, at-spi2-core (>= 2.38), baobab (>= 3.38), caribou (>= 0.4.21), dconf-cli (>= 0.38), dconf-gsettings-backend (>= 0.38), eog (>= 3.38), evince (>= 3.38), evolution-data-server (>= 3.36), firefox-esr (>= 78) | firefox (>= 78) | chromium | chromium-browser | epiphany-browser, fonts-cantarell (>= 0.111), gdm3 (>= 3.38), gkbd-capplet (>= 3.26), glib-networking (>= 2.58), gnome-backgrounds (>= 3.38), gnome-bluetooth (>= 3.34), gnome-calculator (>= 3.38), gnome-characters (>= 3.34), gnome-contacts (>= 3.38), gnome-control-center (>= 1:3.38), gnome-disk-utility (>= 3.38), gnome-font-viewer (>= 3.34), gnome-keyring (>= 3.36), gnome-logs (>= 3.36), gnome-menus (>= 3.36), gnome-online-accounts (>= 3.36), gnome-online-miners (>= 3.34), gnome-session (>= 3.38), gnome-settings-daemon (>= 3.38), gnome-shell (>= 42), gnome-shell-extensions (>= 42), gnome-software (>= 3.36), gnome-sushi (>= 3.34), gnome-system-monitor (>= 3.38), gnome-terminal (>= 3.44) | gnome-console (>= 42~beta), gnome-text-editor | gedit (>= 3.36), gnome-themes-extra (>= 3.28), gnome-user-docs (>= 3.38), gnome-user-share (>= 3.34), gsettings-desktop-schemas (>= 3.38), gstreamer1.0-packagekit, gstreamer1.0-plugins-base (>= 1.14), gstreamer1.0-plugins-good (>= 1.18), gvfs-backends (>= 1.46), gvfs-fuse (>= 1.46), libatk-adaptor (>= 2.38), libcanberra-pulse, libglib2.0-bin, libpam-gnome-keyring (>= 3.36), libproxy1-plugin-gsettings, libproxy1-plugin-webkit, librsvg2-common, nautilus (>= 3.38), pulseaudio | pipewire-pulse, pulseaudio-module-bluetooth | libspa-0.2-bluetooth, sound-theme-freedesktop, system-config-printer-common, system-config-printer-udev, totem (>= 3.38), tracker, xdg-desktop-portal-gnome (>= 41~), yelp (>= 3.38), zenity (>= 3.32)

gnome-shell-extension-prefs

Gnome shell extension prefs is a GNOME Shell extension that allows users to manage extensions for the GNOME desktop environment.

Gnome shell extension prefs dependencies are as follows:

gir1.2-adw-1, gir1.2-gtk-4.0, gjs (>= 1.71.1), gnome-shell (= 42.0-2ubuntu1), gnome-shell-common (= 42.0-2ubuntu1)

gnome-shell-extension-ubuntu-dock

Gnome Shell Extension Ubuntu Dock is an extension for the GNOME desktop environment that provides a dock for the Ubuntu desktop environment. It is the default taskbar for Ubuntu 17.10 and later.

Gnome shell extenions Ubuntu Doc dependencies are as follows:

gnome-shell (<< 43), gnome-shell (>= 40), dconf-gsettings-backend | gsettings-backend

gnome-shell-extension-appindicator

Gnome shell extension appindicator is a GNOME Shell extension that provides support for application indicators in the GNOME desktop environment.

gnome-shell-extension-desktop-icons-ng

Gnome shell extension desktop icons NG is a desktop icon manager for the GNOME desktop environment. It is a desktop icon manager for GNOME 3, and it is the successor to the Nautilus desktop icons of GNOME 2.

Gnome shell extenions desktop icons NG's dependencies are as follows:

dconf-gsettings-backend | gsettings-backend, file-roller (>= 3.38), gnome-shell (>= 3.38), gjs, nautilus (>= 3.38), xdg-desktop-portal

ubuntu-desktop-minimal

Ubuntu-desktop-minimal is the minimal version of the Ubuntu desktop environment. It contains the software packages required for the minimal installation of the Ubuntu desktop environment.

Obviously, Ubuntu-desktop-minimal depends on gnome-shell, gdm3, etc.

Dependencies are as follows:

alsa-base, alsa-utils, anacron, at-spi2-core, bc, ca-certificates, dmz-cursor-theme, fonts-dejavu-core, fonts-freefont-ttf, foomatic-db-compressed-ppds, gdm3, ghostscript-x, gnome-control-center, gnome-menus, gnome-session-canberra, gnome-settings-daemon, gnome-shell, gnome-shell-extension-appindicator, gnome-shell-extension-desktop-icons-ng, gnome-shell-extension-ubuntu-dock, gstreamer1.0-alsa, gstreamer1.0-packagekit, gstreamer1.0-plugins-base-apps, gstreamer1.0-pulseaudio, inputattach, language-selector-common, language-selector-gnome, libatk-adaptor, libnotify-bin, libsasl2-modules, libu2f-udev, nautilus, openprinting-ppds, printer-driver-pnm2ppa, pulseaudio, rfkill, software-properties-gtk, spice-vdagent, ubuntu-drivers-common, ubuntu-release-upgrader-gtk, ubuntu-session, ubuntu-settings, unzip, update-manager, update-notifier, wireless-tools, wpasupplicant, xdg-user-dirs, xdg-user-dirs-gtk, xkb-data, xorg, yelp, zenity, zip
rt, ubuntu-wallpapers, whoopsie, xcursor-themes, xdg-desktop-portal-gnome, xdg-desktop-portal-gtk, xdg-utils, yaru-theme-gnome-shell, yaru-theme-gtk, yaru-theme-icon, yaru-theme-sound

ubuntu-desktop

Ubuntu-desktop is the standard version of the Ubuntu desktop environment. It contains the software packages required for the standard installation of the Ubuntu desktop environment.

Obviously, Ubuntu-desktop depends on ubuntu-desktop-minimal, gnome-shell, etc.

Dependencies are as follows:

alsa-base, alsa-utils, anacron, at-spi2-core, bc, ca-certificates, dmz-cursor-theme, fonts-dejavu-core, fonts-freefont-ttf, foomatic-db-compressed-ppds, gdm3, ghostscript-x, gnome-control-center, gnome-menus, gnome-session-canberra, gnome-settings-daemon, gnome-shell, gnome-shell-extension-appindicator, gnome-shell-extension-desktop-icons-ng, gnome-shell-extension-ubuntu-dock, gstreamer1.0-alsa, gstreamer1.0-packagekit, gstreamer1.0-plugins-base-apps, gstreamer1.0-pulseaudio, inputattach, language-selector-common, language-selector-gnome, libatk-adaptor, libnotify-bin, libsasl2-modules, libu2f-udev, nautilus, openprinting-ppds, printer-driver-pnm2ppa, pulseaudio, rfkill, software-properties-gtk, spice-vdagent, ubuntu-desktop-minimal, ubuntu-drivers-common, ubuntu-release-upgrader-gtk, ubuntu-session, ubuntu-settings, unzip, update-manager, update-notifier, wireless-tools, wpasupplicant, xdg-user-dirs, xdg-user-dirs-gtk, xkb-data, xorg, yelp, zenity, zip

Conclusion

In this tutorial, you have learned how to run a Linux Desktop environment in a Docker container. This is a simple way to try out Linux Desktop environment without installing it on your local machine.