dduportal / boot2docker-vagrant-box

Packer scripts to build a Vagrant-compatible boot2docker box.
85 stars 32 forks source link

Error on reload of a Vagrant docker container #15

Closed duro closed 9 years ago

duro commented 9 years ago

I am using this box as a proxy box for other Vagrant managed Docker projects. Everytime I run vagrant reload on on of those projects I get the following error:

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

Command: ["sharedfolder", "add", "1b364c41-c16a-4001-9aee-8bf10b180d97", "--name", "vagrant", "--hostpath", "/Users/adamduro/Workspace/docker/vagrant"]

Stderr: VBoxManage: error: The machine 'zg-docker-host' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 1002 of file VBoxManageMisc.cpp

Here is my Vagantfile for the proxy setup that uses this box:

# Vagrantfile for the proxy VM

Vagrant.configure("2") do |config|

  config.vm.define "zg-docker-host", primary: true do |dhost|

    dhost.vm.box = "dduportal/boot2docker"
    dhost.vm.box_version = "= 1.5.0"

    dhost.vm.network :private_network, ip: "192.168.100.200"

    dhost.vm.provider "virtualbox" do |v|
      # On VirtualBox, we don't have guest additions or a functional vboxsf
      # in TinyCore Linux, so tell Vagrant that so it can be smarter.
      v.name = "zg-docker-host"
      v.check_guest_additions = false
      v.memory = 2048
    end

    # b2d doesn't support NFS
    dhost.nfs.functional = false

    dhost.vm.network "forwarded_port", guest: 8080, host: 8080
    dhost.vm.network "forwarded_port", guest: 3000, host: 3000
    dhost.vm.network "forwarded_port", guest: 3232, host: 3232
    dhost.vm.network "forwarded_port", guest: 8888, host: 8888

  end

end

And here is the Vagrant file for a project:

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker'
ENV["DOCKER_HOST_VAGRANT_FILE"] ||= "./docker/Dockerhost"
ENV["DOCKER_HOST_VAGRANT_NAME"] ||= "zg-site-docker-host"

# BUILD ALL WITH: vagrant up --no-parallel

Vagrant.configure("2") do |config|

  config.vm.define "app" do |v|

    v.vm.synced_folder ".", "/opt/app", type: "rsync",
      rsync__exclude: get_ignored_files()

    v.vm.provider "docker" do |d|
      d.vagrant_machine = ENV["DOCKER_HOST_VAGRANT_NAME"]
      d.vagrant_vagrantfile = ENV["DOCKER_HOST_VAGRANT_FILE"]
      d.build_dir = "."
      d.env = { :SITE_HOSTNAME => 'docker.local' }
      d.remains_running = true
      d.ports = ["8003:8003", "8383:8383", "5353:5353"]
    end
  end

end

def get_ignored_files()
  ignore_file   = ".rsyncignore"
  ignore_array  = []

  if File.exists? ignore_file and File.readable? ignore_file
    File.read(ignore_file).each_line do |line|
      ignore_array << line.chomp
    end
  end

  return ignore_array
end
dduportal commented 9 years ago

OK, seems related to NFS at first eye, i have to support that fot the 1.6.0 release.

dduportal commented 9 years ago

Hello @duro , could you please try :

Do not hesitate to re-open the issue if it is not working, with some updated Vagrantfiles.