Hi!
Superviser version : 10.6.27
Host Os version : balenaOS 2.47.0+rev1
Board : Raspberry pi 3 B 1.2
Bluetooth device : on-board Bluetooth or a simple Bluetooth dongle
I’ve been facing this problem for a week now where I want to have a beacon scanner in a node-red container and the Bluetooth device(s) that i use are not visible inside my container but they are visible from the host.
The label “[…].dbus” : 1
I have the “DBUS_SYSTEM_BUS_ADDRESS” inside the docker-compose and my dockerfile set up
The container is privileged
To know if I see my devices, I log onto the host and the container and I use the command “hcitool dev” that list the MAC of my device.
On the host, i see :
Devices: hci0 DE:AD:BE:EF:00:00
But the same operation in container return :
Devices:
To workaround this problem, i found that I could add "network_mode: “host” " to my docker-compose file. This solve this issue but this is not a viable solution for me as I need the network between my containers to still work.
On the container, i now see :
Devices: hci0 DE:AD:BE:EF:00:00
To validate my finding, I use node-red and a beacon scanner node, when the network mode is host, i got data, if network_mode is commented, the node doesn’t work.
The problem I see is that I shouldn’t need to change the network mode to be able to see my Bluetooth devices
This is the stripped down version of my docker-compose and dockerfile that i use to test this. normally, I got other container with that.
DockerCompose:
version: “2.1”
services:
local_mqtt:
environment:
- BROKER_IP=changeme
build: ./local_mqtt
ports:
- 1883:1883bluetooth:
build: ./bluetooth
privileged: true
labels:
io.balena.features.dbus: 1
network_mode: “host”
# devices:
# - /var/run/dbus:/var/run/dbus
environment:
- “DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket”
ports:
- 1880:1880
Dockerfile
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian-node:12.7-build
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
#Update the image and dependencies
RUN apt-get update
RUN apt-get install -y python-rpi.gpio
RUN apt-get install bluetooth bluez libbluetooth-dev libudev-dev
RUN setcap cap_net_raw+eip $(eval readlink -fwhich node
)
.### Upload the node-red flows, settings and install packages
…
CMD [“npm”, “start”]