From d2983d4fe4774efabd489575a2e7dfa190b6bd99 Mon Sep 17 00:00:00 2001 From: Jason Casden Date: Fri, 7 Aug 2015 13:44:08 -0400 Subject: [PATCH] Use official Docker installer and upgrade for :latest installs --- .../docker/cap/debian/docker_install.rb | 18 +++------------ .../docker/cap/redhat/docker_install.rb | 22 +++++++++++-------- plugins/provisioners/docker/installer.rb | 6 ++--- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/plugins/provisioners/docker/cap/debian/docker_install.rb b/plugins/provisioners/docker/cap/debian/docker_install.rb index b9fbed673..d1dd0222a 100644 --- a/plugins/provisioners/docker/cap/debian/docker_install.rb +++ b/plugins/provisioners/docker/cap/debian/docker_install.rb @@ -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 diff --git a/plugins/provisioners/docker/cap/redhat/docker_install.rb b/plugins/provisioners/docker/cap/redhat/docker_install.rb index 2d6bd1e51..7afd30587 100644 --- a/plugins/provisioners/docker/cap/redhat/docker_install.rb +++ b/plugins/provisioners/docker/cap/redhat/docker_install.rb @@ -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 diff --git a/plugins/provisioners/docker/installer.rb b/plugins/provisioners/docker/installer.rb index cfcebdd43..b144ec1e6 100644 --- a/plugins/provisioners/docker/installer.rb +++ b/plugins/provisioners/docker/installer.rb @@ -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