Bluetooth USB dongle from within docker

I’m trying to use bluetooth from within docker (using the official image). On the host I see the bt dongle

$ lsusb
Bus 003 Device 007: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
...

Also

$ hciconfig dev
hci0:	Type: BR/EDR  Bus: USB
	BD Address: 00:1A:7D:DA:71:13  ACL MTU: 310:10  SCO MTU: 64:8
	UP RUNNING PSCAN ISCAN 
	RX bytes:628 acl:0 sco:0 events:39 errors:0
	TX bytes:1016 acl:0 sco:0 commands:39 errors:0

So on the host I think I’m good.

Now my docker compose contains:

  homeassistant:
    image: homeassistant/home-assistant:latest
    ports:
      - 443:443
    volumes:
      - ./data/home-assistant/:/config
      - /etc/localtime:/etc/localtime:ro
    links:
      - mqtt
    restart: "always"
    devices:
      - /dev/tty
      - /dev/ttyUSB0
      - /dev/ttyUSB1
      - /dev/ttyACM0
    privileged: true

Now from within the container I’m playing around:

# bluetoothd -n
bluetoothd[12474]: Bluetooth daemon 5.23
D-Bus setup failed: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
bluetoothd[12474]: Unable to get on D-Bus
# lsmod | grep bt
btusb                  45056  0 
btrtl                  16384  1 btusb
btbcm                  16384  1 btusb
btintel                16384  1 btusb
bluetooth             520192  24 bnep,btbcm,btrtl,btusb,btintel
btrfs                 987136  0 
xor                    24576  2 btrfs,async_xor
raid6_pq              102400  4 async_pq,raid456,btrfs,async_raid6_recov
# hcitool scan
Device is not available: Address family not supported by protocol

Anyone get this working? What am I missing?

Have you tried running your container with networking in host mode? (network_mode: “host” in your compose file, I think).

I haven’t tried it yet but it’s on my to-do list for presence detection, so I did some research on this subject. Some have reported that in host mode BT basically just works. I know it’s not preferred for other reasons.

I have not. I’ll give that a try and report back. Thanks!

Looks like that worked. Thanks!