First Look at the UBI Init Base Images
Among its catalog of Universal Base Images (UBI), Red Hat provides a kind / flavor prefixed init
.
The UBI
ubi8-init
images contains thesystemd
initialization system, making them useful for building images in which you want to runsystemd
services, such as a web server or file server. […]
Inubi8-init
, theCmd
is set to/sbin/init
, instead ofbash
, to start thesystemd
Init service by default. It includesps
andprocess
related commands (procps-ng
package), whichubi8
does not. […]
Also,ubi8-init
setsSIGRTMIN+3
as theStopSignal
, assystemd
inubi8-init
ignores normal signals to exit (SIGTERM
andSIGKILL
), but will terminate if it receivesSIGRTMIN+3
.
The point seems to be—quick disclaimer: I’m not a specialist at all of this topic, just curious—that different communities have different opinions:
Upstream docker
Upstream docker says any process can run as
PID 1
in a container. And they have proven this by the thousands of docker-formatted container images that are present on their container image registry.
Systemd developers
The systemd developers believe the opposite. They say you should always run an init system as
PID 1
in any environment.
They state thatPID 1
provides services to the processes inside the container that are part of the Linux API. […]
People building docker-formatted images have to build their own Init command for launching the container. They can’t simply use the systemd unit file just the way that the OS and packager intends. This is also part of the Linux Service API.
First try
|
Privileged mode
To run systemd
expects a certain number of things, see Running systemd in a non-privileged container for the detail. A simple way to make it work is to run docker in privileged mode.
When the operator executes docker run –privileged, Docker will enable access to all devices on the host as well as set some configuration in AppArmor or SELinux to allow the container nearly all the same access to the host as processes running outside containers on the host. — Docker run reference
So let’s try by installing and running an Apache HTTP server.
|
Now the Apache start page should be displayed in your preferred web browser at http://localhost.
From a docker image
By defining a simple docker image for that the advantage in terms of simplicity and standardisation are obvious.
|
|
Quick exploration
We can check that the logs are written in the journal.
|
What is the problem?
The main one is that
systemd
/journald
controls the output of containers, whereas tools like Kubernetes and OpenShift expect the containers to log directly tostdout
andstderr
. So, if you are going to manage your containers via Orchestrator like these, then you should think twice about using systemd-based containers. Additionally, the upstream community of Docker and Moby were often hostile to the use ofsystemd
in a container.
Next
To go further it could be interesting to have a look at Podman.
This article explains how and the advantages of using this setup.
I may give it a try in a next article…