简体   繁体   English

如何从 windows 主机访问我的设备到 docker linux 容器?

[英]How can I access my device from a windows host to a docker linux container?

I have a desktop with Windows 10 and an elgato capture card.我有一个带有 Windows 10 和一个 elgato 采集卡的桌面。 I am using OpenCV to capture the frames of the video for processing.我正在使用 OpenCV 来捕获视频帧进行处理。 So far, everything works perfectly fine:到目前为止,一切正常:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Our operations on the frame come here
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # Display the resulting frame
    cv2.imshow('frame', gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

The next step I want to do is utilize the Remote Development Extensions .我想做的下一步是利用Remote Development Extensions This extension, with VS Code, works perfectly fine for my other python projects.这个带有 VS Code 的扩展非常适合我的其他 python 项目。 This is the first project I am writing that utilizes a hardware device, but my linux container cannot access the hardware that the host has access to.这是我编写的第一个使用硬件设备的项目,但是我的 linux 容器无法访问主机可以访问的硬件。 I attempted to search for a solution, but all I have found is a way for using the --device parameter in my docker command with the examples pointing from a *nix device path to another *nix device path.我试图寻找解决方案,但我发现的只是一种在我的docker命令中使用--device参数的方法,示例从 *nix 设备路径指向另一个 *nix 设备路径。

I did come across a post from the docker desktop team that is over two (2) years old saying that you cannot access hardware from a windows host to a linux container.我确实遇到过两 (2) 岁以上的 docker 桌面团队的帖子,说您无法从 windows 主机访问硬件到 linux 容器。 I'm not sure if that is still the case, and I'm not sure if the remote containers extension has a way to access the devices... there is some magic that goes on in that the extension installs a vscode-server on the container, so I'm not sure if that would allow hardware access?我不确定情况是否仍然如此,并且我不确定远程容器扩展是否有办法访问设备......有一些神奇之处在于扩展安装了一个 vscode-server容器,所以我不确定这是否允许硬件访问?

According to Microsoft's Official documentation , you can't share a device from a Windows Host to a Linux container.根据 Microsoft 的官方文档,您不能将设备从 Windows 主机共享到 Linux 容器。 You can however share a device to a Windows container, but I guess this isn't what you want.但是,您可以将设备共享到 Windows 容器,但我想这不是您想要的。

You can however use docker-machine to share your devices, this is because docker-machine uses a Virtual Machine such a VirtualBox instead of their custom engine to run the container's processes.但是,您可以使用docker-machine来共享您的设备,这是因为 docker-machine 使用诸如 VirtualBox 之类的虚拟机而不是其自定义引擎来运行容器的进程。

Once you have docker-machine installed you can simply execute the command安装 docker-machine 后,您可以简单地执行命令

docker-machine create --driver virtualbox <A name for the machine>

Then you open VirtualBox which should be in your programs and add the device manually.然后你打开应该在你的程序中的 VirtualBox 并手动添加设备。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Windows 10主机访问Linux Docker Container的TCP端口 - How to access Linux Docker Container's TCP Port from windows 10 host 如何在 linux 主机上运行 windows docker 容器? - How to run a windows docker container on linux host? 如何在Windows的Docker linux容器中从ASP.NET Core公开端口? - How can I expose a port from ASP.NET Core in Docker linux container in Windows? 如何使用Docker Desktop / Hyper-V / MobyLinuxVM从Windows主机LAN透明地访问Linux容器 - How to acces transparently Linux container from Windows host LAN with Docker Desktop / Hyper-V / MobyLinuxVM 如何访问在Windows OS的Docker工具箱Linux容器中创建的项目目录? - How can I access the project directories that are created in the Docker toolbox Linux containers on my Windows OS? Windows Host和Linux Docker Container之间的通信 - Communication between Windows Host and Linux Docker Container 在带有线保护的 docker 容器中时,为什么我只能从 docker 主机访问 nginx 而不能远程访问? - When in a docker container with wireguard, why can I only access nginx from the docker host and not remotely? 有没有办法可以将挂载点文件从 Windows 主机绑定到 linux 容器? - Is there a way I can bind mount dot files from a windows host to a linux container? Docker 容器无法从主机访问映射目录 - Docker container can't access mapped directory from host 无法从容器连接到我的Docker主机Postgresql数据库 - Can't connect to my docker host postgresql database from a container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM