Developing KDE with Docker


Docker can help you to quickly set up a development environment for working on a software project. This is great for getting new contributors up to speed quickly. I’ve recently discovered how nice this is and want to share how I use Docker.

KDE projects often have desktop services, mimetypes and plugins. Ideally, these are installed system-wide. During development it is not convenient to change your main environment just to test your software. This is where Docker comes in. Docker is the most popular Linux container system. It gives you a system that is separate from your main system and which you can rewind when you break it.

Dolphin in KDE neon

The simplest way to get going is to run a fresh Plasma system. KDE neon provides Docker images.

After installing Docker, you can get a system going like this;


cleans up the container after use.


makes the session interactive.

-e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix

gives the container access to your X session.

an empty home
Dolphin running in a throwaway Docker container. No home directory was set up.

Dolphin in openSUSE

Instead of kdeneon/plasma:dev-stable you might want to use a different distribution. You can build you own images by creating your own Dockerfile. Here is a simple Dockerfile for a Docker image for dolphin based on openSUSE.

FROM opensuse

# opensuse image is minimal, so add plasma and dolphin
RUN zypper --non-interactive install plasma5-desktop dolphin \
  && zypper clean

# set up an environment for a user
RUN useradd --create-home user
USER user
WORKDIR /home/user

CMD ["bash", "-l"]

To create a docker image, write this text into a file name Dockerfile and run

Now a docker image called opensuse-dolphin was created and run. At each uppercased commands like RUN a snapshot is created. The last step is to tag the final snapshot with the name opensuse-dolphin. That name can be used to run a throwaway container with dolphin.

dolphin running in an openSUSE container
Dolphin running in a throwaway Docker container based on openSUSE.

Adding a home

To do any coding, you’d like to provide files to your container and have the ability to store files. This is possible. You can give a container access to a local folder with the -v flag, for example -v $HOME/calligra-dev/home:/home/user which mounts your folder $HOME/calligra-dev/home to the folder /home/user in the container.

I like to manage this container home with git, so I can start with a clean folder by running git clean -fd.

So the development environment is managed by Docker on the system level and by git on the level of work directory.

Developing Calligra in Docker

After this introduction, I’m showing the Dockerfile that I’m using for Calligra with QtCreator or KDevelop and the clazy quality checker. Clazy has not been packaged so the Dockerfile needs to have a build step for it.

FROM kdeneon/plasma:dev-stable

USER root

RUN apt-get update && apt-get dist-upgrade -y

RUN apt-get install -y --no-install-recommends \
  cmake extra-cmake-modules g++ gettext git kdoctools-dev kross-dev \
  libboost-all-dev libeigen3-dev libetonyek-dev libfontconfig1-dev \
  libfreetype6-dev libgit2-dev libgsl-dev libkf5activities-dev \
  libkf5archive-dev libkf5kcmutils-dev libkf5kdelibs4support-dev \
  libkf5notifications-dev libkf5notifyconfig-dev libkf5parts-dev \
  libkf5wallet-dev libkf5xmlgui-dev libodfgen-dev libpoppler-qt5-dev \
  libqca-qt5-2-dev libqt5opengl5-dev libqt5svg5-dev libqt5x11extras5-dev \
  librevenge-dev libwpd-dev libwpg-dev libwps-dev ninja-build pkg-config \

# requirements for clazy
RUN apt-get install -y --no-install-recommends \
  clang llvm-dev libclang-3.8-dev

# build and install clazy
RUN git clone git:// \
  && cd clazy \
  && cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -GNinja \
  && ninja install

# dependencies for development
RUN apt-get install -y --no-install-recommends \
  cmake-curses-gui \
  less vim strace qtcreator kdevelop valgrind gdb

USER neon
CMD ["/bin/bash", "-l"]

Parallel development environments

Docker is easy to set up and lets you have tight control over your development and testing environment. You can have many environments present on your system and reset and start and stop them quickly. Finally, here is a screenshot of my desktop running development environments for Calligra 2 and Calligra 3 in parallel. Both are running in QtCreator. This is a screenshot from my Akademy presentation on Calligra.

Two versions of Calligra running in Docker containers
Two versions of Calligra running in Docker containers.

Helping contributors to get started

Getting started in KDE can be challenging. Docker images or Dockerfiles for complete development environments can get new contributors started more quickly. In KDE, neon already uses Docker images. Jonathan Riddell is giving a presentation about that this Akademy. Because this is so easy, I predict that we’ll see more Dockerfiles being published by KDE projects.


Post a comment

Lightweight than a virtual machine?

From the description, this seems to be more similar to the Python's virtualenv than a heavyweight virtual machine. Is my assumption correct?

If so, then Docker sounds like the best option for me. I want to test waters of KDE development before jumping in, but don't want to pollute my current stable setup of OpenSUSE Leap 42.3. However, development would likely require latest devel packages, which Leap may not provide.

Reply to this comment