Fix the Jenkins Docker error: Permission denied when trying to connect to Docker daemon

Jenkins Docker permission denied error

There’s an easy fix to the “Permission denied while trying to connect to the Docker daemon socket” error you encounter when you run a Jenkins build or a pipeline’s Jenkinsfile that accesses a Docker image. It’s just a single terminal command and then a reboot:

sudo usermod -a -G docker jenkins

Run this command and Jenkins will be able to invoke a Docker run command and the Docker daemon socket issues will go away.

Jenkins Docker Permission Denied fix

To fix the Jenkins Docker permission denied error, just run a usermod command in the terminal and reboot.