Windows/MacOS上のDockerでUbuntuコンテナを立て
コンテナ内でbluez
を利用してBLEペリフェラルと通信したいと思っています。
service bluetooth start
, bluetoothd
, hciconfig
のいずれも失敗し、通信のスキャンができません。
やり方・調べ方があればご教示ください。
環境:
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
Windows/MacOSでやったこと:
# docker run --name <container> --net=host --privileged -it ubuntu /bin/bash
コンテナ側でやったこと:
# apt-get update
# apt-get upgrade -y
# apt-get install -y dbus bluetooth bluez bluez-firmware
# service dbus start
失敗1:bluetooth
を起動してもステータスを見ると起動できていない
# service bluetooth start
* Starting bluetooth
# service bluetooth status
* bluetooth is not running
失敗2:bluetoothd
はインタフェースにアクセスできない
# 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
失敗3:hciconfig
はソケットを開けない
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:
失敗4:btusb
モジュールを追加できない
# 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
参考URL:
- bluetoothd fails with: Failed to access management interfac:
bluez-firmware
をインストールするも変わらず - Bluetooth socket can't be opened inside container:
lsmod
にbtusb
が出ているので状況が違いそう - Accessing Bluetooth dongle from inside Docker?:
/sys/class/bluetooth
が存在しない - Bluetooth module not loaded at startup:
btusb
モジュールを追加できない