I faced the same issue when I was creating Docker images from Jenkins. Simply add the user to the docker
group and then restart Docker services and in my case I had to restart Jenkins services.
This was the error which I got:
http:///var/run/docker.sock/v1.19/build?cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&memory=0&memswap=0&rm=1&t=59aec062a8dd8b579ee1b61b299e1d9d340a1340: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?
FATAL: Failed to build docker image from project Dockerfile
java.lang.RuntimeException: Failed to build docker image from project Dockerfile
Solution:
[root@Jenkins ssh]# groupadd docker
[root@Jenkins ssh]# gpasswd -a jenkins docker
Adding user jenkins to group docker
[root@Jenkins ssh]# /etc/init.d/docker restart
Stopping docker: [ OK ]
Starting docker: [ OK ]
[root@Jenkins ssh]# /etc/init.d/jenkins restart
Shutting down Jenkins [ OK ]
Starting Jenkins [ OK ]
[root@Jenkins ssh]#