Use official Docker installer and upgrade for :latest installs
This commit is contained in:
parent
82fa09ca87
commit
d2983d4fe4
|
@ -4,26 +4,14 @@ module VagrantPlugins
|
||||||
module Debian
|
module Debian
|
||||||
module DockerInstall
|
module DockerInstall
|
||||||
def self.docker_install(machine, version)
|
def self.docker_install(machine, version)
|
||||||
package = 'lxc-docker'
|
package = 'docker-engine'
|
||||||
package << "-#{version}" if version != :latest
|
package << "-#{version}" if version != :latest
|
||||||
|
|
||||||
machine.communicate.tap do |comm|
|
machine.communicate.tap do |comm|
|
||||||
comm.sudo("apt-get update -y")
|
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("apt-get install -y --force-yes -q curl")
|
||||||
comm.sudo("curl -sSL https://get.docker.com/gpg | apt-key add -")
|
comm.sudo("apt-get purge -y lxc-docker*")
|
||||||
comm.sudo("echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list")
|
comm.sudo("curl -sSL https://get.docker.com/ | sh")
|
||||||
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")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,28 +8,32 @@ module VagrantPlugins
|
||||||
machine.ui.warn(I18n.t("vagrant.docker_install_with_version_not_supported"))
|
machine.ui.warn(I18n.t("vagrant.docker_install_with_version_not_supported"))
|
||||||
end
|
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")
|
case machine.guest.capability("flavor")
|
||||||
|
|
||||||
when :rhel_7
|
when :rhel_7
|
||||||
docker_install_rhel7(machine)
|
docker_enable_rhel7(machine)
|
||||||
else
|
else
|
||||||
docker_install_default(machine)
|
docker_enable_default(machine)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.docker_install_rhel7(machine)
|
def self.docker_enable_rhel7(machine)
|
||||||
machine.communicate.tap do |comm|
|
machine.communicate.tap do |comm|
|
||||||
comm.sudo("yum -y install docker")
|
|
||||||
comm.sudo("systemctl start docker.service")
|
comm.sudo("systemctl start docker.service")
|
||||||
comm.sudo("systemctl enable docker.service")
|
comm.sudo("systemctl enable docker.service")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.docker_install_default(machine)
|
def self.docker_enable_default(machine)
|
||||||
machine.communicate.tap do |comm|
|
machine.communicate.tap do |comm|
|
||||||
if ! comm.test("rpm -qa | grep epel-release")
|
comm.sudo("service docker start")
|
||||||
comm.sudo("rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm")
|
comm.sudo("chkconfig docker on")
|
||||||
end
|
|
||||||
comm.sudo("yum -y install docker-io")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,10 +15,10 @@ module VagrantPlugins
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if !@machine.guest.capability(:docker_installed)
|
@machine.ui.detail(I18n.t("vagrant.docker_installing", version: @version.to_s))
|
||||||
@machine.ui.detail(I18n.t("vagrant.docker_installing", version: @version.to_s))
|
@machine.guest.capability(:docker_install, @version)
|
||||||
@machine.guest.capability(:docker_install, @version)
|
|
||||||
|
|
||||||
|
if !@machine.guest.capability(:docker_installed)
|
||||||
if !@machine.guest.capability(:docker_installed)
|
if !@machine.guest.capability(:docker_installed)
|
||||||
raise DockerError, :install_failed
|
raise DockerError, :install_failed
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue