images bajar vagrant

bajar - vagrant up



Cómo depurar el mensaje "Vagrant no puede reenviar los puertos especificados en esta máquina virtual" (8)

Estoy intentando iniciar una instancia de Vagrant y aparece el siguiente mensaje:

Vagrant cannot forward the specified ports on this VM, since they would collide with another VirtualBox virtual machine''s forwarded ports! The forwarded port to 4567 is already in use on the host machine. To fix this, modify your current projects Vagrantfile to use another port. Example, where ''1234'' would be replaced by a unique host port: config.vm.forward_port 80, 1234

Abrí VirtualBox, pero no tengo ninguna caja en ejecución en este momento, así que estoy perplejo. ¿Cómo puedo averiguar qué proceso está escuchando en 4567? ¿Hay alguna manera de enumerar todos los cuadros de Vagrant que se ejecutan en mi máquina?

Gracias kevin


Como dice el mensaje, el puerto colisiona con la caja del host. Simplemente cambiaría el puerto a otro valor en la máquina host. Así que si estoy recibiendo error por

config.vm.forward_port 80, 1234

entonces lo cambiaría a

config.vm.forward_port 80, 5656

Como 1234 podría ser utilizado en mi máquina host.

Para inspeccionar realmente los puertos en cualquier máquina, uso la utilidad tcpview para ese sistema operativo y conozco qué puerto se usa dónde.


Encontré este problema porque tenía una máquina virtual que intentaba ejecutar Postgres y tenía Postgres ejecutándose en mi máquina local en el puerto 5432.

Después de vagrant resume , recibí el error:

Vagrant no puede reenviar los puertos especificados en esta máquina virtual, ya que chocarán con alguna otra aplicación que ya está escuchando en estos puertos. El puerto reenviado a 5432 ya está en uso en la máquina host.

Busque lo que se está ejecutando en el puerto 5432:

o-ets-webdeveloper:portal me$ lsof -i :5432 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME postgres 1389 me 5u IPv6 0x681a62dc601cf1e3 0t0 TCP localhost:postgresql (LISTEN) postgres 1389 me 6u IPv4 0x681a62dc6499362b 0t0 TCP localhost:postgresql (LISTEN)

Resulta que es Postgres local, matando esos procesos me permitió ejecutar un vagrant resume éxito.


Lo arreglé de esta manera:

  1. vagrant suspend
  2. Cerrar proyecto en RubyMine IDE
  3. vagrant resume
  4. Abrir reciente en RubyMine IDE

Me encontré con este problema y resultó que RubyMine todavía se aferraba a un puerto. Descubrí qué aplicación mantenía en el puerto (31337 en mi caso) ejecutando este comando:

lsof -i | grep LISTEN

Salida

node 1396 richard.nienaber 7u IPv4 0xffffff802808b320 0t0 TCP *:20559 (LISTEN) Dropbox 1404 richard.nienaber 19u IPv4 0xffffff8029736c20 0t0 TCP *:17500 (LISTEN) Dropbox 1404 richard.nienaber 25u IPv4 0xffffff8027870160 0t0 TCP localhost:26165 (LISTEN) rubymine 11668 richard.nienaber 39u IPv6 0xffffff8024d8e700 0t0 TCP *:26162 (LISTEN) rubymine 11668 richard.nienaber 65u IPv6 0xffffff8020c6e440 0t0 TCP *:31337 (LISTEN) rubymine 11668 richard.nienaber 109u IPv6 0xffffff8024d8df80 0t0 TCP localhost:6942 (LISTEN) rubymine 11668 richard.nienaber 216u IPv6 0xffffff8020c6ef80 0t0 TCP localhost:63342 (LISTEN)


Puede ver qué instancias errantes se están ejecutando en su máquina ejecutando

$ vagrant global-status id name provider state directory ---------------------------------------------------------------------- a20a0aa default virtualbox saved /Users/dude/Downloads/inst-MacOSX 64bc939 default virtualbox saved /Users/dude/svn/dev-vms/ubuntu14 a94fb0a default virtualbox running /Users/dude/svn/dev-vms/centos5

Si no ves ninguna máquina virtual en ejecución, tu conflicto no es un cuadro errante (ese vagrant sabe). Lo siguiente que debe hacer es iniciar la interfaz de usuario de VirtualBox y verificar si tiene alguna instancia en ejecución. Si no desea ejecutar la interfaz de usuario, puede:

ps -ef |grep VBox

Si tiene instancias de VirtualBox en ejecución, deberían incluirse en esa salida. Debería poder simplemente matar procesos que tienen VirtualBox en su salida. Uno de los problemas es que parece existir uno de esos procesos para mantener alérgicos. Simplemente elimine el proceso más alto de VirtualBox. Si tiene una imagen de VirtualBox en ejecución pero vagrant no lo sabe, es posible que algunos directorios de Vagrant se hayan eliminado manualmente, lo que significa que Vagrant pierde la pista de la instancia.


Si usa Proxifier (o una aplicación similar), intente cerrarlo primero. Este fue un problema que experimenté debido a Proxifier en OSX 10.9.


También tenga en cuenta que (al menos en Vagrant 1.6.4) está la carpeta ~/.vagrant.d/data/fp-leases , con archivos que tienen nombres como 8080 , 8081 , etc. Borrar el contenido de esta carpeta me ayudó en este momento.


Tenga cuidado, su Vagrantfile no es el único que se utiliza al abrir una caja / instancia de Vagrant.

Cuando recibas esto:

~/dev/vagrant user$ vagrant reload Vagrant cannot forward the specified ports on this VM, since they would collide with some other application that is already listening on these ports. The forwarded port to 8001 is already in use on the host machine. To fix this, modify your current projects Vagrantfile to use another port. Example, where ''1234'' would be replaced by a unique host port: config.vm.network :forwarded_port, guest: 8001, host: 1234 Sometimes, Vagrant will attempt to auto-correct this for you. In this case, Vagrant was unable to. This is usually because the guest machine is in a state which doesn''t allow modifying port forwarding. ~/dev/vagrant user$

En realidad, no solo está utilizando el Vagrantfile de ~ / dev / vagrant, sino también el archivo de .box de distribución de su "caja", que normalmente se encuentra aquí:

~/.vagrant.d/boxes/trusty/0/virtualbox/Vagrantfile

Y si lo observa, verá que tiene muchas asignaciones de puertos predeterminadas :

$ cat ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile $script = <<SCRIPT bzr branch lp:jujuredirector/quickstart /tmp/jujuredir bash /tmp/jujuredir/setup-juju.sh SCRIPT Vagrant.configure("2") do |config| # This Vagrantfile is auto-generated by ''vagrant package'' to contain # the MAC address of the box. Custom configuration should be placed in # the actual ''Vagrantfile'' in this box. config.vm.base_mac = "080027DFD2C4" config.vm.network :forwarded_port, guest: 22, host: 2122, host_ip: "127.0.0.1" config.vm.network :forwarded_port, guest: 80, host: 6080, host_ip: "127.0.0.1" config.vm.network :forwarded_port, guest: 8001, host: 8001, host_ip: "127.0.0.1" config.vm.network "private_network", ip: "172.16.250.15" config.vm.provision "shell", inline: $script end # Load include vagrant file if it exists after the auto-generated # so it can override any of the settings include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__) load include_vagrantfile if File.exist?(include_vagrantfile)

Por lo tanto, siga adelante y edite este archivo para eliminar el (los) puerto (s) de reenvío de datos entrantes:

config.vm.network :forwarded_port, guest: 22, host: 2122, host_ip: "127.0.0.1" config.vm.network :forwarded_port, guest: 80, host: 6080, host_ip: "127.0.0.1" # config.vm.network :forwarded_port, guest: 8001, host: 8001, host_ip: "127.0.0.1"

Por:

~/dev/vagrant user$ cp ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile.old ~/dev/vagrant user$ vi ~/.vagrant.d/boxes//trusty/0/virtualbox/Vagrantfile

y cuidado con la inclusión de otros archivos Vagrant, es decir:

include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)

Y ahora funciona:

$ vagrant up Bringing machine ''default'' up with ''virtualbox'' provider... ==> default: Importing base box ''trusty''... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: vagrant_default_1401234565101_12345 ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 => 2122 (adapter 1) default: 80 => 6080 (adapter 1) 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... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /vagrant => /Home/user/dev/vagrant/vagrant-docker ==> default: Running provisioner: shell... default: Running: inline script ...

Espero que esto ayude.