Accessing Bluetooth dongle from inside Docker?

前端 未结 4 748
逝去的感伤
逝去的感伤 2021-02-08 02:29

Is it possible to use a bluetooth (BLE in my case) dongle inside of a docker container?

On my host machine:

$ hcitool dev
    Devices:
       hci0   5C:F         


        
4条回答
  •  清酒与你
    2021-02-08 02:39

    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.7
    
    RUN apt-get update
    
    RUN apt-get install -y bluez bluetooth
    
    ENTRYPOINT sh docker_entrypoint.sh
    

    and entrypoint:

    #!/bin/bash
    
    service dbus start
    bluetoothd &
    
    /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
    

提交回复
热议问题