3

I'm trying to run a Linux application inside a docker container that expects the machine to support Bluetooth connections so it crashes with a "Can't open HCI socket" error.

Now, the Bluetooth functionality is actually not needed for my specific use-case so I could manage with some sort of dummy Bluetooth driver that, for example, just acts like there are no other Bluetooth devices in range.

Is there any easy way to create such a virtual Bluetooth device inside a docker container? I cannot run the container in privileged mode or use the host's Bluetooth resources.

0

1 Answer 1

4
+25

Partial answer: I played around a bit, and found the kernel module hci_vhci, which binds to /dev/vhci and allows to create virtual host controller interfaces.

Finding something that actually uses this kernel module was a bit harder. Apparently at one point there was a program hciemu which did at least partly simulate a HCI interface, but it seems to have vanished from most distributions.

Also, I couldn't find any documentation.

But anyway, after downloading a still accessible tar file with source code (that doesn't seem to be linked from the main download page any longer), compiling it, and doing

# modprobe hci_vhci
# hciemu localhost:10

I ended up with a HCI interface,

$ hciconfig
hci0:   Type: Primary  Bus: Virtual
    BD Address: 7F:00:00:01:00:0A  ACL MTU: 192:8  SCO MTU: 0:0
    DOWN 
    RX bytes:0 acl:0 sco:0 events:8 errors:0
    TX bytes:36 acl:0 sco:0 commands:8 errors:0

This may or may not be enough for your use case.

If anyone can figure out how to actually make use of those interfaces, I'd be very interested.

1
  • 1
    Here modprobe would require the docker to run in privileged mode, isn't it? There's now also emulator/btvirt in bluez by the way. Commented Nov 17, 2021 at 16:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .