Open SirLouen opened 2 months ago
I am also unable to get a bluetooth adapter to work in Docker with WSL2.
uname -r
5.15.153.1-microsoft-standard-WSL2
Trying to load the development environment for Home Assistant and the particular integration I am testing requires a bluetooth connection to the hardware. So passing a dedicated USB bluetooth adapter seemed like the easiest solution but could not get it working because of this issue.
Trying to load the development environment for Home Assistant and the particular integration I am testing requires a bluetooth connection to the hardware. So passing a dedicated USB bluetooth adapter seemed like the easiest solution but could not get it working because of this issue.
Too bad that docker for windows is closed source, and they take 3 months to even triage the issues... Yes I'm in a similar situation, willing to test over WSL on my main windows computer, but I ended testing with a Raspberry PI over VNC, baremetal.
Please see my post here https://github.com/microsoft/WSL/issues/12234 about how I got BT working with a WSL-based devcontainer.
One critical difference I can see between my solution and what OP @SirLouen is trying, is I do not try to run bluetoothd inside of the container. Instead, you run all of that on the WSL host, and then you bind dbus to the container.
Though I note that you seem to have tried this as well, I wonder if it was on a clean container where the container itself didn't have dbus etc?
Theres a layer of abstraction in my solution in that I'm also dealin with home assistant and that uses devcontainer, which is a docker wrapper. But notice how the paths are bound in the above post.
Description
Theoretically the solution was already there, someone did it and documented
But I've found that integrating a Bluetooth Dongle with Windows is not so trivial as commented there. Maybe it is because the stack has upgraded and since this is a 2 year old post, perhaps some new flaws have arisen.
I've tried to implement most ideas I've read both here and Github. Most questions regarding this topic are based on a Linux host (like Raspberry Pi), not over Windows/WSL. For example this: https://stackoverflow.com/questions/28868393/accessing-bluetooth-dongle-from-inside-docker/64126744
I've read plenty of posts in Github being this one of the most thorough.
Now I'm going to describe and reproduce the steps taking based on the suggesting and how it's not working despite all ideas I've read so far.
Reproduce
2.1 Dockerfile
2.2 docker_entrypoint.sh
2.3 Stopping Bluetooth service in the WSL host
sudo service bluetooth stop
2.4. Build the image and start it with:
This is the full setup recommended in 100% of the places I've seen.
Expected behavior
Theoretically now that the WSL host is not serving Bluetooth it should work straight on the docker image:
First, the device is there:
Second,
bluetoothd
, despite being run in the entrypoint is not actually running:I also tried running the image sharing system bus socket, instead of using the
--net=host
thing with:But the same results as the ones above.
docker version
docker info
Diagnostics ID
77F07B67-A67F-4B23-86A1-9FBE325F6292/20240825181036
Additional Info
Although everything seems to be perfectly in order hardware-wise, it's not within the docker container. I have spent countless hours reading posts unsuccessfully, and now I'm giving up, at this point I'm completely lost, and have not found any more references to keep moving forward.