-
Notifications
You must be signed in to change notification settings - Fork 3
Executing the Docker Command Without Sudo
By default, running the docker command requires root privileges — that is, you have to prefix the command with sudo. It can also be run by a user in the docker group, which is automatically created during the installation of Docker. If you attempt to run the docker command without prefixing it with sudo or without being in the docker group, you'll get an output like this:
Output docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?. See 'docker run --help'.
If you want to avoid typing sudo whenever you run the docker command, add your username to the docker group:
sudo gpasswd -a $(whoami) docker
You will need to log out of the machine and back in as the same user to enable this change.
If you need to add a user to the docker group that you're not logged in as, declare that username explicitly using:
sudo gpasswd -a username docker