Accessing Bluetooth dongle from inside Docker? Accessing Bluetooth dongle from inside Docker? docker docker

Accessing Bluetooth dongle from inside Docker?


Try this:

sudo docker run --net=host --privileged -i -t ubuntu /bin/bash


If you want to run bluez from a docker (and not only expose hci adapter) you need:

  • To start your docker with sudo docker run --privileged -i -t your_image_name /bin/bash
  • Make sure bluez is not running on your host. In my case I add to kill bluez (killall -9 bluetoothd) (and not stopped it properly as it will power down my bluetooth adapter and will not exposed it into the docker)
  • In your docker entrypoint, you will need to start dbus (/etc/init.d/dbus start) and bluez (/usr/libexec/bluetooth/bluetoothd --debug &)


I can confirm that what OlivierM wrote is working on me. Spent some time on Raspberry Pi 3B+ and its built-in bluetooth.

Dockerfile:

FROM python:3.7RUN apt-get updateRUN apt-get install -y bluez bluetoothENTRYPOINT sh docker_entrypoint.sh

and entrypoint:

#!/bin/bashservice dbus startbluetoothd &/bin/bash

sudo killall -9 bluetoothd is needed on host machine before before starting the container:

docker run --rm --net=host --privileged -it myimage:mytag