I’m working on a custom extension for the docker daemon which relies on accessing an external service through dbus. As far as I can tell, putting this code into components/engine/daemon.containerCreate
should work:
conn, err := dbus.SystemBus()
if err != nil { fmt.Printf("Failed to connect to system bus: %v\n", err); return errors.New("Failed"); }
obj := conn.Object(objectBus, objectPath)
call := obj.Call(methodName, 0)
if call.Err != nil { fmt.Printf("Failed to call dbus method: %v\n", err); return errors.New("Failed"); }
But this always produces the output, Failed to call dbus method: dbus: connection closed by user
. Building exactly the same code into a standalone executable works correctly.
I’ve also tried using dbus.SystemBusPrivate
but then the method call hangs.
Has anyone developing docker seen this? Is there some trick to getting dbus to work?