title: Why does my docker build fail on jenkins agent?
body: <p>Here is my <code>Jenkinsfile</code> pipeline in a project</p>
  
  <pre><code>pipeline {
      agent {
          docker {
              image 'docker:dind'
              args '-u root:root -p 3000:3000 --privileged'
          }
      }
  
      environment {
          CI = 'true'
      }
  
      stages {
          stage('docker build') {
              when {
                  branch 'master'
              }
              steps {
                  sh 'docker build --label v1.0.0 -t myrepo/myapp:v1.0.0'
              }
          }
      }
  }
  </code></pre>
  
  <p>And I have a jenkins master and slave agent respectively. The above pipeline works well in master node, but if run in a slave agent node, then it would met the following error:</p>
  
  <pre><code>Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
  </code></pre>
  
  <p>I am pretty sure that docker is running on the agent node because I can ssh to it and run docker commands successfully.</p>
  
  <p>Why it behaves differently between running on master and slave agent? How should I fix it? Thanks very much!</p>