用Docker破坏stream氓专用networking

我使用默认的Docker Vagrantfile通过Vagrant创build一个Virtualbox 虚拟机 。 build造这个vm的vagrant up可以像预期的那样工作,并提供一个可以运行的箱子。

然后我需要转发端口的能力,并将以下内容添加到Vagrantfile

 Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| config.vm.network :forwarded_port, :host => 5432, :guest => 5432 # postgres # ... more port forwardings end 

这工作,但我后来意识到,我需要在两个方向的端口转发。 我试图为这个问题创build一个专用networking,而不是转发每个端口。 以下添加到configuration应该做的伎俩:

 Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| config.vm.network :private_network, ip: "172.17.0.2" end 

但是,这会在创build虚拟机时触发错误:

 > vagrant up Bringing machine 'default' up with 'virtualbox' provider... [default] Clearing any previously set forwarded ports... [default] Creating shared folders metadata... [default] Clearing any previously set network interfaces... [default] Preparing network interfaces based on configuration... [default] Forwarding ports... [default] -- 22 => 2222 (adapter 1) [default] Running 'pre-boot' VM customizations... [default] Booting VM... [default] Waiting for machine to boot. This may take a few minutes... The guest machine entered an invalid state while waiting for it to boot. Valid states are 'starting, running'. The machine is in the 'poweroff' state. Please verify everything is configured properly and try again. If the provider you're using has a GUI that comes with it, it is often helpful to open that and watch the machine, since the GUI often has more helpful error messages than Vagrant can retrieve. For example, if you're using VirtualBox, run `vagrant up` while the VirtualBox GUI is open. 

任何想法如何debugging和解决这个问题?

主机操作系统:Arch Linux

VM OS:Ubuntu(请参阅上面的Vagrantfile链接)

从Arch Linux Wiki开始 :

要确保桥接networking的全部function,请确保已加载vboxnetadpvboxnetfltvboxpci内核模块,并且已安装net-tools软件包。

内核模块

问题是用于在虚拟机中创build专用networking的内核模块需要单独加载:

 sudo modprobe -a vboxnetadp vboxnetflt 

要在每次重新启动后使此更改保持永久,请将以下行放在/etc/modules-load.d/virtualbox.conf

 vboxdrv vboxnetadp vboxnetflt 

net-tools需要安装:

 sudo pacman -S net-tools 

您还需要virtualbox-host-modules软件包才能使专用networking生机勃勃:

 sudo pacman -S virtualbox-host-modules