// CheckCgroupsAndAdjustConfig checks if we're running rootless with the systemd
// cgroup manager. In case the user session isn't available, we're switching the
// cgroup manager to cgroupfs.  Note, this only applies to rootless.
CheckCgroupsAndAdjustConfig checks if we're running rootless with the systemd
cgroup manager. In case the user session isn't available, we're switching the
cgroup manager to cgroupfs.  Note, this only applies to rootless.
// CheckCgroupsAndAdjustConfig checks if we ' re running rootless with the systemd // cgroup manager . In case the user session isn ' t available we ' re switching the // cgroup manager to cgroupfs . Note this only applies to rootless .
func (c *Config) CheckCgroupsAndAdjustConfig() {
	if !unshare.IsRootless() || c.Engine.CgroupManager != SystemdCgroupsManager {
		return
	}
	session := os.Getenv("DBUS_SESSION_BUS_ADDRESS")
	hasSession := session != ""
	if hasSession && strings.HasPrefix(session, "unix:path=") {
		_, err := os.Stat(strings.TrimPrefix(session, "unix:path="))
		hasSession = err == nil
	}
	if !hasSession {
		logrus.Warningf("The cgroups manager is set to systemd but there is no systemd user session available")
		logrus.Warningf("For using systemd, you may need to login using an user session")
		logrus.Warningf("Alternatively, you can enable lingering with: `loginctl enable-linger %d` (possibly as root)", unshare.GetRootlessUID())
		logrus.Warningf("Falling back to --cgroup-manager=cgroupfs")
		c.Engine.CgroupManager = CgroupfsCgroupsManager
	}
}
func ( c * Config ) CheckCgroupsAndAdjustConfig ( ) { if ! unshare . IsRootless ( ) || c . Engine . CgroupManager != SystemdCgroupsManager { return } session := os . Getenv ( " " ) hasSession := session != " " if hasSession && strings . HasPrefix ( session , " " ) { _ , err := os . Stat ( strings . TrimPrefix ( session , " " ) ) hasSession = err == nil } if ! hasSession { logrus . Warningf ( " " ) logrus . Warningf ( " " ) logrus . Warningf ( " " , unshare . GetRootlessUID ( ) ) logrus . Warningf ( " " ) c . Engine . CgroupManager = CgroupfsCgroupsManager } }
CheckCgroupsAndAdjustConfig checks if we're running rootless with the systemd
cgroup manager.
CheckCgroupsAndAdjustConfig checks if we ' re running rootless with the systemd cgroup manager .