Giter Club home page Giter Club logo

vagrant-inside-docker's Introduction

noswpatv3 About

Running vagrant inside a docker container. We use a small box based on OpenWRT 15.05 as a lightweight distro (7MB).

Requirements

You need vagrant kernel modules on the host.

But why?

To quote the FOSDEM2017 presentation on "Running virtual machines in containers":

https://fosdem.org/2017/schedule/event/virtcontainers/

The idea of running virtual machines inside containers is surprisingly old and
was used due to several reasons. They include willingness to run VM-s in
container orchestration engines like Kubernetes or Borg, or packaging IaaS
cloud software like OpenStack in containers. In this presentation, I am going
to describe these use cases and two main different approaches of containerizing
VM-s - putting every qemu(-kvm) process in a separate container (like Borg or
Rancher OS are doing) and putting libvirtd process in container (like OpenStack
Kolla or Stackanetes are doing)

Usage

Just launch ./run.sh

Oneliner

You can also run it as a oneliner:

docker run --privileged -v /dev/vboxdrv:/dev/vboxdrv -v /dev/vboxnetctl:/dev/vboxnetctl -it zoobab/vagrant-inside-docker:latest /bin/bash -c "vagrant up && vagrant ssh"

Screenshot

Everybody love screenshots:

Vagrant running inside a Docker container with OpenWRT as small distro

zoobab@filez /home/zoobab/vagrant-inside-docker [33]$ ./run.sh 
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'living42/openwrt-15.05-x86'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'living42/openwrt-15.05-x86' is up to date...
==> default: Setting the name of the VM: vagrant-openwrt_default_1487750817274_66403
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 80 (guest) => 8081 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default: 
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 CHAOS CALMER (15.05, r46767)
 -----------------------------------------------------
  * 1 1/2 oz Gin            Shake with a glassful
  * 1/4 oz Triple Sec       of broken ice and pour
  * 3/4 oz Lime Juice       unstrained into a goblet.
  * 1 1/2 oz Orange Juice
  * 1 tsp. Grenadine Syrup
 -----------------------------------------------------
vagrant@OpenWrt:~$ 

Bugs

  • Sometimes docker stop takes time to stop the running container, or never stops it :-)
  • Sometimes virtualbox of the GUEST container is very sensitive to the version of the HOST, so the closer they are the better.
  • I had to upgrade and do some debian pinning to have virtualbox and vagrant from Ubuntu Zesty while the rest of the distro was still on Xenial. Will provide a pinning example once I have it working.

Links

vagrant-inside-docker's People

Contributors

jlegido avatar zoobab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vagrant-inside-docker's Issues

input/output error

tried to run after adding the file-sharing settings and I get this:

docker: Error response from daemon: lstat /dev/vboxdrv: input/output error.

Any ideas on how to fix?

VBoxManage: error: The host network interface named 'vboxnet0' could not be found

Hi,

I'm getting below error when I tried to set ipaddress in Vagrantfile, Is there a way to make it work while using network settings?

config.vm.network "private_network", ip: "10.0.10.21"

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "ipconfig", "vboxnet0", "--ip", "10.0.10.1", "--netmask", "255.255.255.0"]

Stderr: VBoxManage: error: The host network interface named 'vboxnet0' could not be found
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component HostWrap, interface IHost, callee nsISupports
VBoxManage: error: Context: "FindHostNetworkInterfaceByName(Bstr(pszName).raw(), hif.asOutParam())" at line 231 of file VBoxManageHostonly.cpp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.