Use official Docker installer and upgrade for :latest installs

This commit is contained in:
Jason Casden 2015-08-07 13:44:08 -04:00 committed by Seth Vargo
parent 82fa09ca87
commit d2983d4fe4
3 changed files with 19 additions and 27 deletions

View File

@ -4,26 +4,14 @@ module VagrantPlugins
module Debian
module DockerInstall
def self.docker_install(machine, version)
package = 'lxc-docker'
package = 'docker-engine'
package << "-#{version}" if version != :latest
machine.communicate.tap do |comm|
comm.sudo("apt-get update -y")
# TODO: Perform check on the host machine if aufs is installed and using LXC
if machine.provider_name != :lxc
# Attempt to install linux-image-extra for this kernel, if it exists
package_name = "linux-image-extra-`uname -r`"
comm.sudo("lsmod | grep aufs || modprobe aufs || apt-cache show #{package_name} && apt-get install -y #{package_name} || true")
end
comm.sudo("apt-get install -y --force-yes -q curl")
comm.sudo("curl -sSL https://get.docker.com/gpg | apt-key add -")
comm.sudo("echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list")
comm.sudo("apt-get update")
comm.sudo("echo lxc lxc/directory string /var/lib/lxc | debconf-set-selections")
comm.sudo("apt-get install -y --force-yes -q xz-utils #{package} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'")
# chmod the directory if it exists
comm.sudo("chmod 0755 /var/lib/docker")
comm.sudo("apt-get purge -y lxc-docker*")
comm.sudo("curl -sSL https://get.docker.com/ | sh")
end
end
end

View File

@ -8,28 +8,32 @@ module VagrantPlugins
machine.ui.warn(I18n.t("vagrant.docker_install_with_version_not_supported"))
end
machine.communicate.tap do |comm|
comm.sudo("yum -y update")
comm.sudo("yum -y remove docker-io*")
comm.sudo("curl -sSL https://get.docker.com/ | sh")
end
case machine.guest.capability("flavor")
when :rhel_7
docker_install_rhel7(machine)
docker_enable_rhel7(machine)
else
docker_install_default(machine)
docker_enable_default(machine)
end
end
def self.docker_install_rhel7(machine)
def self.docker_enable_rhel7(machine)
machine.communicate.tap do |comm|
comm.sudo("yum -y install docker")
comm.sudo("systemctl start docker.service")
comm.sudo("systemctl enable docker.service")
end
end
def self.docker_install_default(machine)
def self.docker_enable_default(machine)
machine.communicate.tap do |comm|
if ! comm.test("rpm -qa | grep epel-release")
comm.sudo("rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm")
end
comm.sudo("yum -y install docker-io")
comm.sudo("service docker start")
comm.sudo("chkconfig docker on")
end
end
end

View File

@ -15,10 +15,10 @@ module VagrantPlugins
return
end
if !@machine.guest.capability(:docker_installed)
@machine.ui.detail(I18n.t("vagrant.docker_installing", version: @version.to_s))
@machine.guest.capability(:docker_install, @version)
@machine.ui.detail(I18n.t("vagrant.docker_installing", version: @version.to_s))
@machine.guest.capability(:docker_install, @version)
if !@machine.guest.capability(:docker_installed)
if !@machine.guest.capability(:docker_installed)
raise DockerError, :install_failed
end