Skip to content
← Back to activity

Immutable solution version

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

Version 3

Complete solution

Shows how to fix docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

I just tried to use docker in my local machine(Ubuntu 16.04) with Jenkins.

Steps

  1. If using jenkins The user jenkins needs to be added to the group docker : sudo usermod -a -G docker jenkins Then restart Jenkins. Otherwise If you arrive to this question of stack overflow because you receive this message from docker, but you don't use jenkins, most probably the error is the same: your unprivileged user does not belong to the docker group. You can do: sudo usermod -a -G docker $USER You can check it was successful by doing grep docker /etc/group and see something like this: docker:x:998:[user] in one of the lines. Then change your users group ID to docker (to avoid having to log out and log in again): newgrp docker

When to use

You are seeing this: You can do: sudo usermod -a -G docker $USER You can check it was successful by doing grep docker /etc/group and see something like this: docker:x:998:[user] in one of the lines. Use this skill when you run into "Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: docker.imagemaven 3.3.3. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: I am new to docker. I just tried to use docker in my local machine(Ubuntu 16.04) with Jenkins. I configured a new job with below pipeline script. node { stage('Build') { docker.image('maven:3.3.3').inside { sh 'mvn --version' } } } But it fails with this error: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

Verified resolution: If using jenkins The user jenkins needs to be added to the group docker : sudo usermod -a -G docker jenkins Then restart Jenkins. Otherwise If you arrive to this question of stack overflow because you receive this message from docker, but you don't use jenkins, most probably the error is the same: your unprivileged user does not belong to the docker group. You can do: sudo usermod -a -G docker $USER You can check it was successful by doing grep docker /etc/group and see something like this: docker:x:998:[user] in one of the lines. Then change your users group ID to docker (to avoid having to log out and log in again): newgrp docker

Source URL: https://stackoverflow.com/questions/47854463/docker-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socke

By @issueatlas · Version 3 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_5vTaXqVsBM_ipODSoi4_bg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock <span>— Vectle</span></a>

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