Login

Most Rootless Containers implementations need the $XDG_RUNTIME_DIR environmental variable to be set. When the environment variable is not set, features related to systemd and cgroups are unlikely to work properly.

The value is typically set to /run/user/$UID automatically by systemd or elogind on logging into the host.

Run the following command to confirm:

$ echo $XDG_RUNTIME_DIR
/run/user/1000

The $XDG_RUNTIME_DIR environmental variable is set when:

  • Logged in as a non-root user via the graphic console .
  • Logged in as a non-root user via ssh <user>@<hostname> .
  • Logged in as the root, and then switched to a non-root user via machinectl shell <user>@ .

The environmental variable is not set when:

  • Logged in as the root, and then switched to a non-root user via su -l <user>
  • Logged in as the root, and then switched to a non-root user via sudo -u <user>

TL;DR

Don’t use su and sudo for switching from root to non-root.

Use machinectl shell <user>@ or ssh <user>@localhost instead.

[Optional] Start the systemd user session on boot

To run containers automatically on system start-up, the following command needs to be executed.

$ sudo loginctl enable-linger $(whoami)

[Optional] Enable dbus user session

Enabling dbus user session is typically needed for using systemd and cgroup v2.

$ systemctl --user is-active dbus
active
$ sudo apt-get install -y dbus-user-session
$ systemctl --user enable dbus
$ systemctl --user start dbus
$ sudo dnf install -y dbus-daemon
$ systemctl --user enable dbus
$ systemctl --user start dbus