# Accessing dbus services in docker daemon code

**URL:** <https://forums.mobyproject.org/t/accessing-dbus-services-in-docker-daemon-code/364>\
**Category:** Uncategorized\
**Created:** [February 20, 2019, 9:13pm UTC](https://forums.mobyproject.org/t/accessing-dbus-services-in-docker-daemon-code/364 "2019-02-20T21:13:52Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![tomkcook](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@tomkcook](https://forums.mobyproject.org/u/tomkcook)\
**Post date:** [February 20, 2019, 9:13pm UTC](https://forums.mobyproject.org/t/accessing-dbus-services-in-docker-daemon-code/364/1 "2019-02-20T21:13:52Z")

</div>

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:

```auto
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?

---

_[View the full topic](https://forums.mobyproject.org/t/accessing-dbus-services-in-docker-daemon-code/364)._
