I was getting this error when I was trying to run a docker container using jenkins declarative pipeline script. This was being run on my localhost and below is what I needed to correct it.
Added jenkins user to docker group
The solution that actually worked was to change the permission of the sock file to 666
Once this was done my pipeline script started working!