5

I have an Ubuntu container in Docker on Windows/MacOS.

I'd like to use bluez to communicate with BLE peripherals in the container.

service bluetooth start, bluetoothd, and hciconfig all fail to scan for communication.

Please let me know if there is any way to do or find out how to do this.

Environments :

Windows 10 Home -> Docker v20.10.14 -> Ubuntu 22.04 LTS (Jammy Jellyfish)
MacOS Monterey 12.3.1 ->  Docker v20.10.12 -> Ubuntu 22.04.4 LTS

What I did on Windows/MacOS :

# docker run --name <container> --net=host --privileged -it ubuntu /bin/bash

What I did on the container side :

# apt-get update 
# apt-get upgrade -y
# apt-get install -y dbus bluetooth bluez bluez-firmware
# service dbus start 

Failure 1: bluetooth is not activated after I started it

# service bluetooth start
 * Starting bluetooth
# service bluetooth status
 * bluetooth is not running

Failure 2: bluetoothd cannot access the interface

# bluetoothd -dn
bluetoothd[2292]: Bluetooth daemon 5.64
bluetoothd[2292]: src/main.c:parse_config() parsing /etc/bluetooth/main.conf
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “DiscoverableTimeout” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “AlwaysPairable” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “PairableTimeout” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “Privacy” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “JustWorksRepairing” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “TemporaryTimeout” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “Name” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “Class” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “DeviceID” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “ReverseServiceDiscovery” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have key “RemoteNameRequestRetryDelay” in group “General”
bluetoothd[2292]: src/main.c:parse_config() Key file does not have group “GATT”
(...)
bluetoothd[2292]: src/main.c:parse_mode_config() Key file does not have group “LE”
bluetoothd[2292]: src/adapter.c:adapter_init() Failed to access management interface
bluetoothd[2292]: src/main.c:main() Adapter handling initialization failed

Failure 3: hciconfig can't open the socket

root@docker-desktop:/# hciconfig
Can't open HCI socket.: Address family not supported by protocol
root@docker-desktop:/# hcitool scan
Device is not available: Address family not supported by protocol
root@docker-desktop:/# hcitool dev
Devices:

Failure 4: Cannot add btusb module

# lsmod
Module                  Size  Used by
# modprobe btusb
(Windows)
modprobe: FATAL: Module btusb not found in directory /lib/modules/5.10.16.3-microsoft-standard-WSL2
(MacOS)
modprobe: FATAL: Module btusb not found in directory /lib/modules/5.10.76-linuxkit

Reference URL:

isexxx
  • 727
  • 1
  • 6
  • 23
  • On MacOS, Docker runs inside a hidden Linux VM, and it will be extremely difficult to use the host's hardware devices. Can you run the application outside a container, using the OS-native facilities to access the Bluetooth stack? The tasks you show don't look like this is a programming question and you also might ask on a MacOS- or Linux-specific forum. – David Maze May 30 '22 at 10:29
  • @DavidMaze I'd like to run same program on both Mac/Windows.That doesn't seem to be possible... I may need to change my thinking. I was having a hard time because I stumbled on this before I started working on it. Thnx your advice. – isexxx Jun 01 '22 at 05:45

0 Answers0