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:
- bluetoothd fails with: Failed to access management interfac: Installed
bluez-firmware, but still the same - Bluetooth socket can't be opened inside container:
btusbinlsmodresult at this site, so I guess the situation is different - Accessing Bluetooth dongle from inside Docker?:
/sys/class/bluetoothdoes not exist - Bluetooth module not loaded at startup: Cannot add
btusbmodule