Developer tip: test MariaDB install/upgrade quickly with Docker

Here is a quick tip for any developer who might want to test if the latest development version of MariaDB installs/upgrades. Traditionally, developers seem to have a bunch of virtual machines lying around which they use to test MariaDB installation and upgrade related things. Snapshotting virtual images, keeping them up-to-date, starting, stopping etc. takes a lot of time and does not feel very convenient.

A much faster option would be to use pristine Docker images for every test. Docker images however normally only run one process and thus do not simulate a complete operating system and lack vital things like systemd interactions.

For this scenario however, special Docker images exist thanks to ubuntu-systemd and centos-systemd images by Solita. Here is how to start an Ubuntu 18.04 image with systemd running inside:

1. Prepare cgroup permissions

docker run --rm --privileged -v /:/host solita/ubuntu-systemd:18.04 setup

2. Start container

docker run -d --name systemd --security-opt seccomp=unconfined --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro -t solita/ubuntu-systemd:18.04

3. Check logs that it started well

docker logs systemd
systemd 237 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
Detected virtualization docker.
Detected architecture x86-64.

Welcome to Ubuntu 18.04 LTS!

Set hostname to <8dcf4b869050>.
File /lib/systemd/system/systemd-journald.service:36 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.
Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)
[ OK ] Started Dispatch Password Requests to Console Directory Watch.
[ OK ] Reached target Swap.
[ OK ] Started Forward Password Requests to Wall Directory Watch.
[ OK ] Reached target Local Encrypted Volumes.
-.slice: Failed to reset devices.list: Operation not permitted
user.slice: Failed to reset devices.list: Operation not permitted
[ OK ] Created slice User and Session Slice.
system.slice: Failed to reset devices.list: Operation not permitted
[ OK ] Created slice System Slice.
[ OK ] Reached target Slices.
[ OK ] Listening on /dev/initctl Compatibility Named Pipe.
system-getty.slice: Failed to reset devices.list: Operation not permitted
[ OK ] Created slice system-getty.slice.
[ OK ] Listening on Journal Socket (/dev/log).
[ OK ] Reached target Remote File Systems.
[ OK ] Reached target Paths.
[ OK ] Listening on Journal Socket.
[ OK ] Reached target Local File Systems (Pre).
[ OK ] Reached target Local File Systems.
systemd-journald.service: Failed to reset devices.list: Operation not permitted
Starting Journal Service...
[ OK ] Started Journal Service.

4. Attach your session and run your tests!


docker exec -it systemd bash
root@8dcf4b869050:/#

If you want to, for example, use the PPA we have for test builds on Launchpad (which is updated only sporadically, not on every build) you can run these commands:

apt install software-properties-common
add-apt-repository ppa:mysql-ubuntu/mariadb-10.3
apt-get update
apt install mariadb-server

The benefit of this approach is that it is quick. Downsides include, for example, the inability to test how systemd scripts behave during restarts. Also, there do not seem to be that many pre-built images available to test any version of any Linux distribution.

If you have more related tips, please comment below!