Software⏱️ 2 min read📅 2026-05-31

How to Fix: Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

Docker permission denied error on Ubuntu 16.04 with Jenkins pipeline script.

Quick Answer: Ensure Docker is installed and running correctly, and that the user running the Jenkins job has the necessary permissions to access the Docker daemon socket.

The 'Got permission deniedwhile trying to connect to the Docker daemon socket at unix:///var/run/docker.sock' error occurs when Docker is unable to establish a connection with its socket. This issue can be resolved by running Docker as a non-root user or by modifying the permissions of the Docker socket.

🛑 Root Causes of the Error

  • Incorrect Docker socket location or permissions.

🛠️ Step-by-Step Verified Fixes

Method 1: Running Docker as a Non-Root User

  1. Step 1: Run the Docker command with the --user option to specify the user to run Docker as.

Method 2: Modifying Docker Socket Permissions

  1. Step 1: Run the command 'sudo setfacl -R -m user::rwx /var/run/docker.sock' to modify the Docker socket permissions.

✨ Wrapping Up

To resolve the 'Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock' error, try running Docker as a non-root user or modify the Docker socket permissions. If you encounter any issues, refer to the official Docker documentation for further assistance.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions