Skip to content

Commit 23c6e4f

Browse files
authored
Merge pull request #3212 from AkihiroSuda/cherrypick-3186
[1.0] rootless+cgroup2+systemd: improve error message when dbus-user-session is not installed #3186
2 parents 04bcb7c + cbb5ef5 commit 23c6e4f

File tree

1 file changed

+5
-1
lines changed
  • libcontainer/cgroups/systemd

1 file changed

+5
-1
lines changed

libcontainer/cgroups/systemd/dbus.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package systemd
44

55
import (
66
"context"
7+
"fmt"
78
"sync"
89

910
systemdDbus "github.com/coreos/go-systemd/v22/dbus"
@@ -54,7 +55,10 @@ func (d *dbusConnManager) getConnection() (*systemdDbus.Conn, error) {
5455

5556
conn, err := d.newConnection()
5657
if err != nil {
57-
return nil, err
58+
// When dbus-user-session is not installed, we can't detect whether we should try to connect to user dbus or system dbus, so d.dbusRootless is set to false.
59+
// This may fail with a cryptic error "read unix @->/run/systemd/private: read: connection reset by peer: unknown."
60+
// https://github.com/moby/moby/issues/42793
61+
return nil, fmt.Errorf("failed to connect to dbus (hint: for rootless containers, maybe you need to install dbus-user-session package, see https://github.com/opencontainers/runc/blob/master/docs/cgroup-v2.md): %w", err)
5862
}
5963
dbusC = conn
6064
return conn, nil

0 commit comments

Comments
 (0)