title: RPi3: Bluetooth BlueZ working locally but not in Docker
body: <p>i'm working on HashtagChris <strong>bluetooth</strong> library for C# (<a href="https://github.com/hashtagchris/DotNet-BlueZ" rel="nofollow noreferrer">https://github.com/hashtagchris/DotNet-BlueZ</a>). The scan sample is working on my <strong>raspberry Pi</strong> perfectly, but not in a Docker container. I can detect the Bluetooth chip with adapter hci0 as seen on below screenshot (so I know I have enough privilege for the container to access the chip), but the cs program doesn't seem to find it when executing (i'm running the app through a <strong>dockerfile</strong>, in an <strong>Azure IoT Edge</strong> context).
  <a href="https://i.stack.imgur.com/IroIf.png" rel="nofollow noreferrer">Execution logs</a></p>
  
  <p>Even when I run GetAdaptersAsync() to find all available adapters, with another error:
  <a href="https://i.stack.imgur.com/8GlQM.png" rel="nofollow noreferrer">Execution logs 2</a></p>
  
  <p>uname -a:
  <a href="https://i.stack.imgur.com/6qr7t.png" rel="nofollow noreferrer">System info</a></p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM microsoft/dotnet:2.1-sdk AS build-env
  WORKDIR /app
  USER root
  
  COPY *.csproj ./
  RUN dotnet restore
  COPY . ./
  RUN dotnet publish -c Release -o out
  
  FROM microsoft/dotnet:2.1-runtime-stretch-slim-arm32v7
  WORKDIR /app
  USER root
  
  RUN apt update -y &amp;&amp; \
      apt install -y build-essential systemd bluez bluez-tools bluez-hcidump     \
      bluez-obexd libbluetooth3 libglib2.0-dev libboost-all-dev     libbluetooth-dev \
      rfkill dbus-x11 nano pciutils util-linux libcap-dev \
      pulseaudio-module-bluetooth git bc libusb-dev libdbus-1-dev libudev-    dev \
      libical-dev libreadline-dev autoconf libncurses5-dev wget \
      pulseaudio-module-bluetooth
  
  RUN cd ~ &amp;&amp; \
      wget https://s3.amazonaws.com/json-c_releases/releases/json-c-    0.13.tar.gz &amp;&amp; \
      tar -xvf json-c-0.13.tar.gz &amp;&amp; \
      cd json-c-0.13/ &amp;&amp; \
      ./configure --prefix=/usr --disable-static &amp;&amp; \
      make -j8 &amp;&amp; \
      make install -j8 &amp;&amp; \
      rm -rf json-c-0.13.tar.gz json-c-0.13
  
  RUN cd ~ &amp;&amp; \
      wget https://mirrors.edge.kernel.org/pub/linux/libs/ell/ell-0.6.tar.xz     &amp;&amp; \
      tar -xvf ell-0.6.tar.xz &amp;&amp; \
      cd ell-0.6/ &amp;&amp; \
      ./configure --prefix=/usr &amp;&amp; \
      make -j2 &amp;&amp; \
      make install -j2 &amp;&amp; \
      rm -rf ell-0.6.tar.xz ell-0.6
  
  RUN cd ~ &amp;&amp; \
      wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz &amp;&amp; \
      tar -xvf bluez-5.50.tar.xz &amp;&amp; \
      cd bluez-5.50/ &amp;&amp; \
      ./configure --enable-mesh --prefix=/usr --mandir=/usr/share/man --    sysconfdir=/etc --localstatedir=/var &amp;&amp; \
      make -j2 &amp;&amp; \
      make install -j2 &amp;&amp; \
      rm -rf bluez-5.50.tar.xz bluez-5.50/ &amp;&amp; \
      cp /usr/lib/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd-    543.orig &amp;&amp; \
      ln -sf /usr/libexec/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd
  
  COPY --from=build-env /app/out ./
  COPY --from=build-env /app/launch.sh ./
  
  RUN chmod 777 ./launch.sh
  ENTRYPOINT ["/bin/bash", "./launch.sh"]
  </code></pre>
  
  <p>Launch script:</p>
  
  <pre><code>#!/bin/bash
  
  YELLOW="\e[0;93m"
  NC="\e[0m"
  
  echo -e "$YELLOW\n\n Launching Script...$NC"
  
  export DISPLAY=:0.0
  
  echo -e "$YELLOW Starting DBus Service...$NC"
  service dbus start; sleep 1; echo -e '\n';
  
  echo -e "$YELLOW Starting Bluetooth Service...$NC"
  service bluetooth start
  bluetoothd -v
  
  echo -e "$YELLOW HCIConfig: Activating hci0...$NC"
  hciconfig hci0 up
  hciconfig hci0 piscan
  hciconfig hci0 sspmode 1
  hciconfig -a
  #rfcomm watch hci0
  
  echo -e "$YELLOW rfkill list$NC"
  rfkill list
  
  echo -e "$YELLOW hcitool dev$NC"
  hcitool dev
  
  echo -e "$YELLOW ls /sys/class/bluetooth$NC"
  ls /sys/class/bluetooth
  
  echo -e "$YELLOW journalctl -xb | grep blue$NC"
  journalctl -xb | grep blue
  
  echo -e "$YELLOW Launching Main Function$NC"
  dotnet BluetoothModule.dll
  
  echo -e "$YELLOW Terminating Script...\n\n$NC"
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2vETl.png" rel="nofollow noreferrer">JSON Deployment template, mounts and binds</a></p>
  
  <p>Thanks for your help!</p>