尝试使用VBoxManage在Docker容器内创build虚拟(仅主机)适配器时出错

我试图在一个Docker镜像中运行VirtualBox(我知道这个问题是可能的),还需要在Docker镜像中设置一个虚拟适配器的主机专用networking。

我在我的Docker容器中安装了VirtualBox。 我知道VirtualBox需要一些内核级驱动程序,这些驱动程序需要在主机系统上加载,而且我需要在运行映像时加载/ dev卷。 即使它们已加载到主机上,并将该卷装入Docker容器中,但尝试运行该命令时也是如此

sudo VBoxManage hostonlyif create 

我得到以下错误:

 0%... Progress state: NS_ERROR_FAILURE VBoxManage: error: Failed to create the host-only adapter VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: Operation not permitted VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg*)" at line 71 of file VBoxManageHostonly.cpp 

有人知道我在做什么错吗? 是否需要Docker – 特权标志?

编辑

使用–privileged = true运行容器解决了创build适配器的问题(尽pipe这只是一个临时解决scheme); 然而(不出所料,当你想到它),它会在主机上而不是在容器内创build一个适配器。 有什么办法使用VBoxManage,我可以在Docker容器中创build主机专用的networking适配器?