diff --git a/CHANGELOG.md b/CHANGELOG.md index 08e5a9ca0..14230d060 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ BUG FIXES: retryable to avoid spurious VirtualBox errors. [GH-2831] - providers/virtualbox: Config validation catches invalid keys. [GH-2843] - 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/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/linux/docker_configure_vagrant_user.rb b/plugins/provisioners/docker/cap/linux/docker_configure_vagrant_user.rb index f88fff3b9..e65a33d4f 100644 --- a/plugins/provisioners/docker/cap/linux/docker_configure_vagrant_user.rb +++ b/plugins/provisioners/docker/cap/linux/docker_configure_vagrant_user.rb @@ -4,7 +4,13 @@ module VagrantPlugins module Linux module DockerConfigureVagrantUser def self.docker_configure_vagrant_user(machine) - machine.communicate.sudo("usermod -a -G docker #{machine.config.ssh.username || "vagrant"}") + ssh_info = machine.ssh_info + + machine.communicate.tap do |comm| + if !comm.test("id -Gn | grep docker") + comm.sudo("usermod -a -G docker #{ssh_info[:username]}") + end + end end end end