Private Network broken in Vagrant with Docker

I create a Virtualbox vm via Vagrant by using the default Docker Vagrantfile. Building the vm with vagrant up works as expected and provides a running box to work with.

I then needed the ability to forward ports and added the following to the Vagrantfile:

  • What is the most light weight base image I can use to build a docker file?
  • How to run docker to other server machine
  • Gitlab CI runner not able to expose ports of nested Docker containers
  • Hibernate database configuration for cloud deployment
  • What does Kubernetes actually do? [closed]
  • Can I run Docker directly on a non VT-X machine (no Virtual Machine used)? [closed]
  • Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| :forwarded_port, :host => 5432, :guest => 5432 # postgres
      # ... more port forwardings

    This works, but i then realized that i need port forwarding in both directions. I tried to create a private network for this matter instead of forwarding each port. The following addition to the config should have done the trick:

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

    But, this triggers an error while creating the vm:

    > 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.

    Any idea how to debug and resolve this?

    Host OS: Arch Linux

    VM OS: Ubuntu (see Vagrantfile linked above)

  • How will a server running multiple Docker virtual machines handle the TCP limitation?
  • How do I get host networking to work with docker swarm mode
  • docker centos:6.6 image “/bin/sh: java: command not found” java is installed
  • Docker-compose links vs external_links
  • Restore SQL Server database to Linux Docker
  • docker build purely from command line
  • One Solution collect form web for “Private Network broken in Vagrant with Docker”

    From the Arch Linux Wiki:

    To ensure full functionality of bridged networking, ensure that the
    vboxnetadp, vboxnetflt and vboxpci kernel modules are loaded too and
    that the net-tools package is installed.

    Kernel modules

    The issue is that the kernel modules for creating private networks in a virtual machine need to be loaded seperately:

    sudo modprobe -a vboxnetadp vboxnetflt

    To make this change permanent after each reboot, put the following lines in /etc/modules-load.d/virtualbox.conf:



    net-tools needs to be installed:

    sudo pacman -S net-tools

    You also need the virtualbox-host-modules package in order to bring private networks to life:

    sudo pacman -S virtualbox-host-modules
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.