Getting permission denied with docker pipeline on jenkins I have jenkins deployed via helm charts on kubernetes cluster
Now i want to be able to run helm to deploy helm charts applications on my kubernetes cluster and have the following in my jenkinsfile

pipeline {
    agent {
        docker { image 'alpine/helm' }
    }
    stages {
        stage('Deploy') {
            steps {
                sh 'helm ls'
            }
        }
    }
}


I also get kubernetes authentication setup on my jenkins so connection to cluster is fine but the error am getting now is the following

+ docker inspect -f . alpine/helm

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.38/containers/alpine/helm/json: dial unix /var/run/docker.sock: connect: permission denied
[Pipeline] isUnix
[Pipeline] sh
+ docker pull alpine/helm
Using default tag: latest
Warning: failed to get default registry endpoint from daemon (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.38/info: dial unix /var/run/docker.sock: connect: permission denied). Using system default: https://index.docker.io/v1/
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.38/images/create?fromImage=alpine%2Fhelm&amp;tag=latest: dial unix /var/run/docker.sock: connect: permission denied
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE


What am i missing and how to i get out of this error?

Thanks

UPDATE

below are the additions/changes to default values.yaml file of the stable/jenkins helm chart

agent:
  enabled: true
  image: "joao29a/jnlp-slave-alpine-docker"
  tag: "latest"
  customJenkinsLabels: []
  # name of the secret to be used for image pulling
  imagePullSecretName:
  componentName: "jenkins-slave"
  #privileged: false
  privileged: true

  resources:
    requests:
      cpu: "512m"
      memory: "512Mi"
    limits:
      cpu: "512m"
      memory: "512Mi"
  # You may want to change this to true while testing a new image
  alwaysPullImage: false
  # Controls how agent pods are retained after the Jenkins build completes
  # Possible values: Always, Never, OnFailure
  podRetention: "Never"
  # You can define the volumes that you want to mount for this container
  # Allowed types are: ConfigMap, EmptyDir, HostPath, Nfs, Pod, Secret
  # Configure the attributes as they appear in the corresponding Java class for that type
  # https://github.com/jenkinsci/kubernetes-plugin/tree/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes
  # Pod-wide ennvironment, these vars are visible to any container in the agent pod
  envVars: []
  # - name: PATH
  #   value: /usr/local/bin
  volumes:
  # - type: Secret
  #   secretName: mysecret
  #   mountPath: /var/myapp/mysecret
   - type: HostPath
     hostpath: /var/run/docker.sock
     mountPath: /var/run/docker.sock


everything else pretty much same except for ingress hostnames and admin user password...above is most important modification to default values.yaml file
You need to add the jenkins user to the docker group:

# run the following command as root
usermod -aG docker jenkins