From 09955be2cd4a4f368da192057d43643ca7ec0ba8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 21 Jan 2014 20:52:27 -0800 Subject: [PATCH] provisioners/docker: configure auto start properly for new Docker [GH-2874] --- CHANGELOG.md | 2 ++ .../docker/cap/debian/docker_configure_auto_start.rb | 8 ++++++-- plugins/provisioners/docker/installer.rb | 3 ++- templates/locales/en.yml | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c88cafcb5..a8860a423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,8 @@ BUG FIXES: - provisioners/chef: When chowning folders, don't follow symlinks. - provisioners/docker: Only add SSH user to docker group if the user isn't already in it. [GH-2838] + - provisioners/docker: Configuring autostart works properly with + the newest versions of Docker. [GH-2874] - provisioners/salt: Options can now set install type and install args. [GH-2766] - synced\_folders/nfs: NFS entries are pruned on every `vagrant up`, diff --git a/plugins/provisioners/docker/cap/debian/docker_configure_auto_start.rb b/plugins/provisioners/docker/cap/debian/docker_configure_auto_start.rb index 52c438f20..8a04e6cc5 100644 --- a/plugins/provisioners/docker/cap/debian/docker_configure_auto_start.rb +++ b/plugins/provisioners/docker/cap/debian/docker_configure_auto_start.rb @@ -4,8 +4,12 @@ module VagrantPlugins module Debian module DockerConfigureAutoStart def self.docker_configure_auto_start(machine) - if ! machine.communicate.test('grep -q \'\-r=true\' /etc/init/docker.conf') - machine.communicate.sudo("sed -i.bak 's/docker -d/docker -d -r=true/' /etc/init/docker.conf ") + machine.communicate.tap do |comm| + if !comm.test('grep -q \'\-r=true\' /etc/default/docker') + comm.sudo("echo 'DOCKER_OPTS=\"-r=true ${DOCKER_OPTS}\"' >> /etc/default/docker") + comm.sudo("stop docker") + comm.sudo("start docker") + end end end end diff --git a/plugins/provisioners/docker/installer.rb b/plugins/provisioners/docker/installer.rb index f6f66e2cf..8f2fbf2b0 100644 --- a/plugins/provisioners/docker/installer.rb +++ b/plugins/provisioners/docker/installer.rb @@ -16,7 +16,7 @@ module VagrantPlugins end if !@machine.guest.capability(:docker_installed) - @machine.ui.info(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) if !@machine.guest.capability(:docker_installed) @@ -25,6 +25,7 @@ module VagrantPlugins end if @machine.guest.capability?(:docker_configure_auto_start) + @machine.ui.detail(I18n.t("vagrant.docker_configure_autostart")) @machine.guest.capability(:docker_configure_auto_start) else @machine.env.ui.warn I18n.t('vagrant.docker_auto_start_not_available') diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 03b376c8a..fd4590754 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -46,6 +46,8 @@ en: Vagrant doesn't support detecting whether Docker is installed for the guest OS running in the machine. Vagrant will assume it is 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 an specific version of Docker onto the guest machine and the latest version will be installed.