'How to use Bluetooth in Docker Containers on Raspberry Pi 4 without net=host Flag?

I use a Rasperry Pi 4 with Raspberry Pi OS and docker compose. In my compose I have several containers and also several networks. I want to use the embedded Bluetooth in one of the containers. Since the corresponding container is connected to multiple networks, I can not use network_mode: host.

I can confirm that docker run --net=host --privileged -i -t ubuntu /bin/bash works and creates me a container by which I can also use Bluetooth (tested with hcitool lescan). But how can I do this without using network_mode: host (or --net=host)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source