hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.28k stars 4.43k forks source link

Vagrant 2.2.9 : The executable 'docker' Vagrant is trying to run was not found in the %PATH% variable. #11802

Open lpsguilloul opened 4 years ago

lpsguilloul commented 4 years ago

Vagrant version

Vagrant 2.2.9

Host operating system

Windows 10 x64

Guest operating system

centos/7

Vagrantfile

I use two files : Vagrantfile and Host_Vagrantfile

Vagrantfile

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker'
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "jenkins" do |v|
    v.vm.provider "docker" do |d|
      d.force_host_vm = true
      d.image = "jenkins/jenkins:2.190.3-centos"
      d.ports = ["8080:8080"]
      d.vagrant_machine = "dockerhost"
      d.vagrant_vagrantfile = "./Host_Vagrantfile"
    end
  end
end

Host_Vagrantfile

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "dockerhost"
  config.vm.box = "centos/7"
  config.vm.box_version = "2004.01"
  config.vm.provision "docker"
  config.vm.network "forwarded_port", guest: 8080, host: 8080,
      auto_correct: true
  config.vm.network "private_network", ip: "172.28.128.2"
  config.vm.provider :virtualbox do |vb|
    vb.name = "dockerhost"
  end
  config.vm.provision "docker"
  config.vm.hostname = "dockerhost"
end

Debug output

https://gist.github.com/lpsguilloul/7baf85c37d184b7930f44ce97862f0e4

Expected behavior

I'm using docker provider. When vagrant up is executed, vagrant should spin up the VM host and install Docker before executing any docker commands to set up the containers.

Actual behavior

Vagrant doesn't spin up the VM host. It's as if, it's ignoring the vagrant_vagrantfile setting passed to the docker provider.

When I remove "ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker'" and execute vagrant up, I get another error :

_INFO interface: error: There are errors in the configuration of this machine. Please fix the following errors and try again:

vm:

  • A box must be specified.

There are errors in the configuration of this machine. Please fix the following errors and try again:

vm:

  • A box must be specified._

Reinstalling Vagrant as suggested in this feed doesn't work. I was able to reproduce the same behavior with Vagrant 2.2.8.

I even tried the simplest vagrant configuration to be able to use docker provider but nothing worked.

On the contrary, docker provision works perfectly.

Steps to reproduce

  1. execute vagrant up

Thanks for your help.

Best regards, Lourdes

soapy1 commented 4 years ago

Hey there, thanks for the bug report!

From this line the debug log

ERROR vagrant: #<Vagrant::Errors::ProviderNotUsable: The provider 'docker' that was requested to back the machine 'jenkins' is reporting that it isn't usable on this system. The reason is shown below:

It seems like docker is being executed on the host machine, not the dockerhost machine. This happens because Vagrant is checking that docker is usable on the host. This check makes sense when trying to use the docker provider on the host system. However, perhaps it is not needed when executing docker remotely. So, this is a bug with the docker provider usability check.

As a workaround for this issue, you can install docker.

I even tried the simplest vagrant configuration to be able to use docker provider but nothing worked.

In order use the docker provider, docker must be installed on the host machine.