<!--
  canonical-url: https://www.avonture.be/blog/docker-lubuntu
  published:     2024-10-24
  This is a static plain-Markdown mirror generated at build time.
  Visit the canonical URL above for the fully rendered page, with images and interactive components.
-->

# Start lubuntu Desktop in Docker

> Learn how to run the Lubuntu Desktop GUI in a Docker container on Windows using an X Server. A perfect, disposable environment for Linux learning and experimenting.

---
![Start lubuntu Desktop](/img/v2/docker_tips.webp)

**TL;DR**

This article shows how to run a full Lubuntu Desktop GUI inside a Docker container on Windows: build a Dockerfile-based Lubuntu image, install Windows X Server (VcXsrv) to render the display, then `docker run` the container to get a disposable, throwaway Linux desktop ideal for experimenting without touching the host.

During my summer holidays, I've watched this video: [Full Ubuntu GUI in a Container Displayed on Windows (XServer)](https://www.youtube.com/watch?v=WutV6n21dys) and, of course, I wanted to play with it.

The idea is to start a Lubuntu Desktop distribution as a Docker container. Lubuntu is a lightweight Ubuntu distribution designed to be more resource-efficient than the standard Ubuntu.

Using Docker and [Windows X Server](https://sourceforge.net/projects/vcxsrv/), we'll be able to play with Lubuntu just like any other container, i.e. play and drop without any impact on our host. Ideal for learning purposes then.

*This is the "whole desktop" variant. For a single application, see [Docker - Run Graphical User Interfaces - Firefox, Chrome & GIMP](/blog/docker-run-linux-gui); and if you'd rather avoid installing an X Server at all, [Docker - Running some GUI interfaces in the browser](/blog/docker-gui-in-browser) displays them in a browser tab instead.*

## Result

![Lubuntu desktop](./images/lubuntu-desktop.webp)

A full Lubuntu desktop, running inside a Docker container, displayed on the Windows host — no VM, no dual-boot, no trace left once you throw the container away.

## Why it works

* Docker gives us a disposable environment: the whole desktop lives in a container, so nothing touches the host — drop the container and it's gone as if it never existed.
* [Windows X Server](https://sourceforge.net/projects/vcxsrv/) is what actually renders the display: the container sends its GUI output to the X server running on Windows, which draws it on screen.

I encourage you to watch the video [Full Ubuntu GUI in a Container Displayed on Windows (XServer)](https://www.youtube.com/watch?v=WutV6n21dys).

## Step 1 - Create the Dockerfile

There is just one file to create called `Dockerfile` and with this content:

**Dockerfile**

```docker
FROM ubuntu:latest

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y lubuntu-desktop lightdm && \
    rm -rf /var/lib/apt/lists/*

RUN rm -f /run/reboot-required*
RUN echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager
RUN printf '%s\n' \
    '[LightDM]' \
    '[Seat:*]' \
    'type=xremote' \
    'xserver-hostname=host.docker.internal' \
    'xserver-display-number=0' \
    'autologin-user=root' \
    'autologin-user-timeout=0' \
    'autologin-session=Lubuntu' \
    > /etc/lightdm/lightdm.conf.d/lightdm.conf

ENV DISPLAY=host.docker.internal:0.0

CMD service dbus start ; service lightdm start
```

Build the image by running `docker build --tag cavo789/lubuntu .` (remember to replace `cavo789` with your own username).

## Step 2 - Install Windows X Server

Building the image will take a few minutes (the final image will be around 3 GB).

During the creation of the image, please install [Windows X Server](https://sourceforge.net/projects/vcxsrv/). It's just a .exe to install on your Windows machine.

Once installed, run the program. On the first screen, as explained in the video, select *One large window*; click on `Next` and keep all default values then click on `Finish` on the last screen.

![Windows X Server](./images/xserver.webp)

By clicking on `Finish` you'll get a black screen. **It's normal.**

![The X Server black window](./images/xserver-black-window.webp)

## Step 3 - Start the container

Run your container by starting `docker run -t cavo789/lubuntu` and **wait, wait and wait again. If you got warnings on the console, don't worry and still wait**.

You may have to wait a minute before you start to see the Linux Lubuntu desktop, and then you'll still need to wait because the operating system is loading and initializing (since it's the first time you start it) — you'll get the desktop shown at the top of this article.

> **Multi-screen support does not seem to work with X Server:**
>
> During my tests, the display wasn't up to scratch and I had to remove the cable from my second screen to get a correct display.

## Conclusion

Do you realize that we've installed a Linux distribution and launched its GUI as a container? In fact, it's like installing a new PC.

Of course, we'd have to go further than that, e.g. to keep data persistent ([via volumes](/blog/docker-volume)).
