diff --git a/plugins/provisioners/docker/cap/debian/docker_install.rb b/plugins/provisioners/docker/cap/debian/docker_install.rb index b9fbed673..33724f673 100644 --- a/plugins/provisioners/docker/cap/debian/docker_install.rb +++ b/plugins/provisioners/docker/cap/debian/docker_install.rb @@ -3,27 +3,12 @@ module VagrantPlugins module Cap module Debian module DockerInstall - def self.docker_install(machine, version) - package = 'lxc-docker' - package << "-#{version}" if version != :latest - + def self.docker_install(machine) 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 update -qq -y") + comm.sudo("apt-get install -qq -y --force-yes curl") + comm.sudo("apt-get purge -qq -y lxc-docker* || true") + comm.sudo("curl -sSL https://get.docker.com/ | sh") end end end diff --git a/plugins/provisioners/docker/cap/fedora/docker_install.rb b/plugins/provisioners/docker/cap/fedora/docker_install.rb index 16377f410..8feb5b0e2 100644 --- a/plugins/provisioners/docker/cap/fedora/docker_install.rb +++ b/plugins/provisioners/docker/cap/fedora/docker_install.rb @@ -3,11 +3,7 @@ module VagrantPlugins module Cap module Fedora module DockerInstall - def self.docker_install(machine, version) - if version != :latest - machine.ui.warn(I18n.t("vagrant.docker_install_with_version_not_supported")) - end - + def self.docker_install(machine) machine.communicate.tap do |comm| if dnf?(machine) comm.sudo("dnf -y install docker") diff --git a/plugins/provisioners/docker/cap/redhat/docker_install.rb b/plugins/provisioners/docker/cap/redhat/docker_install.rb index 2d6bd1e51..0a6868b8b 100644 --- a/plugins/provisioners/docker/cap/redhat/docker_install.rb +++ b/plugins/provisioners/docker/cap/redhat/docker_install.rb @@ -3,33 +3,32 @@ module VagrantPlugins module Cap module Redhat module DockerInstall - def self.docker_install(machine, version) - if version != :latest - machine.ui.warn(I18n.t("vagrant.docker_install_with_version_not_supported")) + def self.docker_install(machine) + machine.communicate.tap do |comm| + comm.sudo("yum -q -y update") + comm.sudo("yum -q -y remove docker-io* || true") + 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/config.rb b/plugins/provisioners/docker/config.rb index bcf4cf672..8e9de55da 100644 --- a/plugins/provisioners/docker/config.rb +++ b/plugins/provisioners/docker/config.rb @@ -4,11 +4,18 @@ module VagrantPlugins module DockerProvisioner class Config < Vagrant.plugin("2", :config) attr_reader :images - attr_accessor :version + + def version=(value) + STDOUT.puts <<-EOH +[DEPRECATED] The configuration `docker.version' has been deprecated. Docker no +longer allows you to specify the version of Docker you want installed and will +automatically choose the best version for your guest. Please remove this option +from your Vagrantfile. +EOH + end def initialize - @images = Set.new - @version = UNSET_VALUE + @images = Set.new @__build_images = [] @__containers = Hash.new { |h, k| h[k] = {} } @@ -65,9 +72,6 @@ module VagrantPlugins end def finalize! - @version = "latest" if @version == UNSET_VALUE - @version = @version.to_sym - @__containers.each do |name, params| params[:image] ||= name params[:auto_assign_name] = true if !params.key?(:auto_assign_name) diff --git a/plugins/provisioners/docker/installer.rb b/plugins/provisioners/docker/installer.rb index cfcebdd43..3f2ae95ad 100644 --- a/plugins/provisioners/docker/installer.rb +++ b/plugins/provisioners/docker/installer.rb @@ -1,9 +1,8 @@ module VagrantPlugins module DockerProvisioner class Installer - def initialize(machine, version) + def initialize(machine) @machine = machine - @version = version end # This handles verifying the Docker installation, installing it if it was @@ -16,12 +15,12 @@ module VagrantPlugins 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")) + @machine.guest.capability(:docker_install) + end - if !@machine.guest.capability(:docker_installed) - raise DockerError, :install_failed - end + if !@machine.guest.capability(:docker_installed) + raise DockerError, :install_failed end if @machine.guest.capability?(:docker_configure_vagrant_user) diff --git a/plugins/provisioners/docker/provisioner.rb b/plugins/provisioners/docker/provisioner.rb index 8b9d609a3..aa4aca27e 100644 --- a/plugins/provisioners/docker/provisioner.rb +++ b/plugins/provisioners/docker/provisioner.rb @@ -11,7 +11,7 @@ module VagrantPlugins def initialize(machine, config, installer = nil, client = nil) super(machine, config) - @installer = installer || Installer.new(@machine, config.version) + @installer = installer || Installer.new(@machine) @client = client || Client.new(@machine) end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 10fee4f09..3367c500a 100755 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -123,14 +123,8 @@ en: installed and attempt to continue. docker_configure_autostart: |- Configuring Docker to autostart containers... - docker_install_with_version_not_supported: |- - Vagrant is not capable of installing a specific version of Docker - onto the guest machine and the latest version will be installed. - This is a limitation of Vagrant knowing how to interact with this - operating system. This isn't a bug, but if you know how to fix this - please report it to Vagrant. docker_installing: |- - Installing Docker (%{version}) onto machine... + Installing Docker onto machine... docker_pulling_images: Pulling Docker images... docker_pulling_single: |- diff --git a/test/unit/plugins/provisioners/docker/config_test.rb b/test/unit/plugins/provisioners/docker/config_test.rb index e12f883c4..ba2b6836d 100644 --- a/test/unit/plugins/provisioners/docker/config_test.rb +++ b/test/unit/plugins/provisioners/docker/config_test.rb @@ -139,15 +139,10 @@ describe VagrantPlugins::DockerProvisioner::Config do end describe "#version" do - it "defaults to latest" do - subject.finalize! - expect(subject.version).to eql(:latest) - end - - it "converts to a symbol" do - subject.version = "v27" - subject.finalize! - expect(subject.version).to eql(:v27) + it "is removed in Vagrant 1.9" do + if Vagrant::VERSION >= "1.9" + raise "Remove deprecated option" + end end end end diff --git a/website/docs/source/v2/provisioning/docker.html.md b/website/docs/source/v2/provisioning/docker.html.md index 0e03ec660..cb0d526fd 100644 --- a/website/docs/source/v2/provisioning/docker.html.md +++ b/website/docs/source/v2/provisioning/docker.html.md @@ -42,9 +42,6 @@ for you (if it isn't already installed). can also use the `pull_images` function. See the example below this section for more information. -* `version` (string) - The version of Docker to install. This defaults to - "latest" and will install the latest version of Docker. - In addition to the options that can be set, various functions are available and can be called to configure other aspects of the Docker provisioner. Most of these functions have examples in more detailed sections below.