title: I want to run Docker command in jenkinsfile but I run into errors
body: <p>I have three stages in jenkinsfile which are</p>
  <ol>
  <li>Lint files</li>
  <li>Variable setup</li>
  <li>Build docker image.<br />
  When I run <code>sh &quot;docker build --tag=hello .&quot;</code> before stage 2, the command builds the docker image but when I run the command after stage 2, Jenkins pipeline will not build the docker image and will return an error <code>process apparently never started in /var/lib/jenkins/workspace/hello@tmp/durable-b5fe7826</code> after about 5 minutes.</li>
  </ol>
  <p>I have attached screenshots</p>
  <p>Screenshot of the image built when I ran docker build before stage 2
  <a href="https://i.stack.imgur.com/bdxH0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bdxH0.png" alt="image built before stage 2" /></a></p>
  <p>Screenshot of the image failed when I ran docker build after stage 2
  <a href="https://i.stack.imgur.com/0M0aV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0M0aV.png" alt="enter image description here" /></a></p>
  <p>Here is my jenkinsfile:</p>
  <pre><code>pipeline {
       agent any
       stages {
            stage(&quot;Lint files&quot;) {
                 steps {
                      echo &quot;Linting HTML file...&quot;
                      sh &quot;tidy -q -e index.html&quot;
                      echo &quot;Linting Dockerfile...&quot;
                      sh &quot;hadolint Dockerfile&quot;
                      sh &quot;docker build --tag=hello1 .&quot;
                 }
            }
            stage(&quot;Variables setup&quot;) {
                 steps {
                      script {
                           echo &quot;Setting up variables for the build&quot;
                           env.tag = readFile(&quot;./variables/tag.txt&quot;).trim()
                           env.name = readFile(&quot;./variables/name.txt&quot;).trim()
                           env.path = readFile(&quot;./variables/path.txt&quot;).trim()
                           name=&quot;${env.name}&quot;
                           tag=&quot;${env.tag}&quot;
                           path=&quot;${env.path}&quot;
                           lo=&quot;name&quot;
                      }
                 }
            }
            stage(&quot;Docker image build&quot;) {
                 steps {
                      echo &quot;Hello Docker&quot;
                      sh &quot;docker build --tag=hello2 .&quot;
                      echo &quot;Hello $name&quot;
                 }
            }
       }
  }
  </code></pre>
  <p>Here is the Docker file code</p>
  <pre><code># hadolint ignore=DL3007
  FROM nginx:latest
  
  # Copy source code to working directory
  COPY index.html /usr/share/nginx/html
  
  # Expose port 80
  EXPOSE 80
  </code></pre>
  <p>I have tried changing the quotes from single to double but no luck.
  How can I fix this?</p>
  <p>PS: I am running Jenkins on AWS EC2 instance</p>