in Developer Experience

Running Vagrant with Docker provider without password prompts on Fedora

When you run Vagrant with Docker provider you find out that you need to prepend every command with sudo since that’s what would you do with running Docker commands directly. But chances are you don’t want to do that. In that case it’s enough to make calls to Docker commands password-less. Vagrant would then be able to use Docker without password prompts as well. To do so you just need add yourself to docker group. Here is how to do it on Fedora 22.

First, if you haven’t already, install Vagrant and Docker:

# dnf install vagrant docker

(You need yum on Fedora 21 and the name of the package was called docker-io before.)

Then you are ready to type:

sudo groupadd docker &&
sudo gpasswd -a ${USER} docker &&
sudo systemctl restart docker &&
newgrp docker

This will create the docker group that is not created by default, add the current running user to this group, restart Docker service and log in to the new group (or you can just log out and log in again). That’s it, now enjoy Vagrant and Docker without typing your password all-the-time.

Note: This has security implications, read about this in the official docs.

Write a Comment

Comment