![](/img/trans.png)
[英]Docker: Mount volume on Windows host - Windows Container
[英]bluetooth in docker for windows host
我的 docker 版本是:
docker --version
Docker version 20.10.2, build 2291f61
我的 windows 版本是:
systeminfo
Nom du système d’exploitation: Microsoft Windows 10 Professionnel
Version du système: 10.0.17763 N/A version 17763
Type du système: x64-based PC
我的 Dockerfile 是:
FROM ubuntu:21.04
RUN apt update
RUN apt-get install -y bluez bluetooth usbutils
當我運行以下命令時,我啟動了“bluetooth_in_docker”容器:
docker build -t bluetooth_in_docker . & docker run --privileged --net=host -it bluetooth_in_docker bash
當我運行以下命令時,在容器內部出現錯誤:
hciconfig dev
Can't open HCI socket.: Address family not supported by protocol
我從 WSL2 內部讓它在 Windows 上工作,但它需要很多步驟。
按照https://github.com/dorssel/usbipd-win/discussions/310讓你的藍牙在 WSL2 中工作。 確認您可以在 WSL2 發行版中掃描藍牙設備。
修改您的 dockerfile 以像您一樣安裝bluetooth
(可能不需要 bluez 和 usb-utils)
現在有2個選項。 第一個選項與容器共享藍牙。 第二個選項賦予容器獨占控制權。
通過掛載 /var/run/dbus 的卷並使用--privileged
運行它,可以在主機和容器之間共享藍牙:
docker run -v /var/run/dbus/:/var/run/dbus/:z --privileged {containerImage}
以這種方式運行容器時,請確保 dbus 和藍牙服務在您的主機中正常工作。
賦予容器獨占控制權:在 WSL2(主機)中,根據https://stackoverflow.com/a/64126744/1114918運行一個 docker 容器
sudo service bluetooth stop
使您的藍牙不被主機“占用”(鏈接的答案使用killall
,我認為sudo service... stop
更干凈)docker run --rm -.net=host --privileged myimage:mytag
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.