Class: VagrantPlugins::Vocker::DockerInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/vocker/docker_installer.rb

Instance Method Summary collapse

Constructor Details

#initialize(machine, version) ⇒ DockerInstaller

Returns a new instance of DockerInstaller.



6
7
8
9
# File 'lib/vocker/docker_installer.rb', line 6

def initialize(machine, version)
  @machine = machine
  @version = version
end

Instance Method Details

#ensure_installedObject

This handles verifying the Docker installation, installing it if it was requested, and so on. This method will raise exceptions if things are wrong.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vocker/docker_installer.rb', line 14

def ensure_installed
  if !@machine.guest.capability?(:docker_installed)
    @machine.ui.warn(I18n.t("vagrant.docker_cant_detect"))
    return
  end

  if !@machine.guest.capability(:docker_installed)
    @machine.ui.info(I18n.t("vagrant.docker_installing"))
    @machine.guest.capability(:docker_install, @version)

    if !@machine.guest.capability(:docker_installed)
      raise Errors::DockerInstallFailed
    end
  end

  if @machine.guest.capability?(:docker_configure_auto_start)
    @machine.guest.capability(:docker_configure_auto_start)
  else
    @machine.env.ui.warn I18n.t('vagrant.docker_auto_start_not_available')
  end

  if @machine.guest.capability?(:docker_configure_vagrant_user)
    @machine.guest.capability(:docker_configure_vagrant_user)
  end
end