Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
2 views
in DevOps and Agile by (47.6k points)

I’m trying to execute a docker image within a Jenkins pipeline but I always come across this error. Any help?

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.26/containers/hello-world/json: dial unix /var/run/docker.sock: connect: permission denied.

1 Answer

+1 vote
by (106k points)

You are getting this error because the Jenkins user is not added to the docker group. So you should first try to create a Jenkins user and add the user to the docker group. Follow the below steps:

1. You can create a docker group if you haven’t done it already by using the following command.

$ sudo groupadd docker

2. After that create a Jenkins user and add it to the docker group by using the following command.

$ sudo usermod -aG docker $USER

3. After completing the above two steps you can log-off, restart your Jenkins and try executing the program. If you’re still getting the same error then change the access permission of the /var/run/docker.sock by using the following command.

$ chmod 777 /var/run/docker.sock

Browse Categories

...