The missing user directory in
/run/user/$UID during Podman execution on RHEL 8.5 typically indicates that the systemd user instance has not started or is inaccessible. This environment variable is critical for rootless containers to communicate with the host system via D-Bus and manage resources correctly. Restoring this directory usually requires ensuring the
systemd --user service is active and properly configured for the current login session.
Understanding the Role of /run/user
On modern Linux systems, including Red Hat Enterprise Linux 8.5, the
/run/user directory serves as a temporary file storage area for each logged-in user. It is mounted by
systemd-logind at login time. When you run Podman commands without root privileges (rootless mode), the container runtime relies heavily on this directory. Specifically, it uses the D-Bus socket located within this path to communicate with the user's session manager. If this directory does not exist or lacks the correct permissions, Podman cannot initialize its internal components, leading to failures or silent errors where the expected runtime environment is absent.
Diagnosing the Missing Directory
Before applying fixes, you must confirm whether the issue is systemic or specific to your current shell session. Start by checking if the directory exists for your user ID. You can determine your UID by running the
id -u command. Then, list the contents of
/run/user using the following command:
ls -ld /run/user/$(id -u)
If the output indicates that the directory does not exist, or if it exists but is owned by
root instead of your user account, the underlying cause is likely related to how your session was initiated. A common scenario occurs when SSH keys are used for authentication without allocating a pseudo-terminal or when services are triggered via cron jobs or systemd unit files that do not start a full user session. In these cases,
systemd-logind may not have initialized the user slice, leaving
/run/user/$UID uncreated.
Ensuring Systemd User Session is Active
The most robust solution involves ensuring that the systemd user instance is running. You can check the status of the user session manager by executing:
systemctl --user status
If this command returns an error stating that the connection to the user bus failed, it confirms that the user session is not active. To resolve this, you should explicitly start the user instance. However, simply starting it manually might not persist across reboots or new sessions. Instead, ensure that your login process triggers the creation of the user slice. For interactive shells, logging out and logging back in often resolves the issue automatically. If you are running scripts, consider wrapping them in a call to
loginctl enable-linger for your user, which ensures the user session persists even after logout, though this is more relevant for background services than immediate runtime fixes.
For immediate remediation in a terminal, you can force the creation of the session directory by invoking a new login shell or restarting the logind service, although restarting logind is risky on production systems. A safer approach is to verify that PAM modules are correctly configured to mount the tmpfs for
/run/user. Check your
/etc/pam.d/system-auth and
/etc/pam.d/password-auth files to ensure that
pam_systemd.so is present and loaded. This module is responsible for creating the necessary directories and setting up the cgroups for the user session.
Is there a way to have macvlan functionality in rootless containers?
This integration between PAM and systemd is crucial because it bridges the gap between the operating system's authentication mechanisms and the user's runtime environment. Without
pam_systemd.so, the system will not automatically prepare the
/run/user hierarchy, causing tools like Podman to fail due to missing sockets or configuration paths.
Alternative Workarounds for Non-Interactive Environments
If you are unable to modify PAM configurations or restart services, you may need to work around the missing directory. One such workaround involves manually creating the directory with appropriate ownership before running Podman commands. Use the following commands to create the directory and set permissions:
mkdir -p /run/user/$(id -u)
chown $(id -u):$(id -g) /run/user/$(id -u)
chmod 700 /run/user/$(id -u)
While this manual fix allows Podman to proceed, it bypasses the intended security model provided by systemd. The manual directory will not be managed by
systemd-logind, meaning it will not be cleaned up automatically upon logout, potentially leading to resource leaks. Furthermore, any D-Bus communication relying on dynamic socket creation may still fail because the socket files themselves are not generated by the system service. Therefore, this method should only be used as a temporary diagnostic step or in highly controlled environments where automatic cleanup is handled by other means.
Another consideration is the use of
machinectl or
loginctl to inspect active sessions. Running
loginctl list-sessions can help identify if your current session is recognized by the system. If your session is missing from this list, it suggests that the login daemon did not register you properly, which is a deeper issue than just the missing directory. In such cases, reviewing journal logs for
systemd-logind errors using
journalctl -u systemd-logind can provide insights into why session registration failed.
Verifying Podman Configuration
Once the
/run/user directory is restored, verify that Podman recognizes the environment. Run
podman info to check if the store and runtime configurations are valid. Pay attention to the "store" section, which should indicate the correct graph root and run root paths. If
podman info succeeds, the issue is resolved. If it still fails, check if your user is part of the
libpod group or if there are SELinux policies blocking access to the newly created directory. Although less common, SELinux contexts can sometimes prevent Podman from accessing the user runtime directory if the labels are incorrect.
RHEL + kill -9 not really killing the process
In summary, the absence of
/run/user/$UID is rarely a standalone bug but rather a symptom of incomplete session initialization. By ensuring that PAM modules load
pam_systemd.so and that users log in through standard interactive methods, you allow systemd to handle the lifecycle of these runtime directories automatically. This approach maintains system integrity and ensures that all user-space daemons and container runtimes have the necessary infrastructure to operate securely and efficiently.
Frequently Asked Questions
Why does /run/user disappear after logout?
By design, systemd cleans up
/run/user directories when the last session for that user ends. This is intentional to free up memory and disk space. If you need persistent data, you should store it in your home directory or use a dedicated service rather than relying on the runtime directory.
Can I disable the requirement for /run/user in Podman?
No, Podman fundamentally relies on the user session bus located in
/run/user for rootless operation. Disabling this requirement would require switching to rootful mode, which defeats the security benefits of rootless containers and requires elevated privileges.
What happens if I manually create /run/user without systemd?
Manually creating the directory allows basic file operations but breaks D-Bus communication. Podman may start containers, but features requiring inter-process communication, such as monitoring or certain network setups, will likely fail because the D-Bus socket is not present or managed correctly.
How do I check if pam_systemd is installed?
You can verify installation by checking for the package
systemd-user or
pam_systemd depending on your distribution. On RHEL, it is included in the base systemd package. You can also check if the module is loaded by looking for
session optional pam_systemd.so in your PAM configuration files.
Does this issue affect Docker as well?
Yes, rootless Docker (Docker CE) faces similar issues because it also depends on the user session bus and runtime directories. If Podman fails due to a missing
/run/user directory, Docker rootless mode will likely encounter identical errors regarding D-Bus connectivity and resource management.