title: Jenkinsfile pipeline: access one docker container from another
body: <p>I have a Jenkinsfile, where I declared 2 stages:<br>
  Stage 1 - where I serve web-server which is create from <code>nginx</code> docker image<br>
  Stage 2 - Running another docker container which is create out of <code>node</code> image and try to connect to <em>container#1</em><br>
  When I run this pipeline I keep getting this error
  <code>(7) Failed to connect to 127.0.0.1 port 80: Connection refused</code>
  I'm new to <code>jenkins-pipeline</code>, <code>docker</code> and <code>devOps</code> in overall, but it kinda looks like that containers are running in different networks or environments or something.</p>
  
  <p>My Jenkinsfile:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>pipeline {
      agent any
      stages {
          stage('Serve') {
              agent {
                  docker { 
                      image "nginx" 
                      args "--name nginx-server -v ${WORKSPACE}/src:/usr/share/nginx/html:ro -d -p 8080:80"
                      reuseNode true
                  } 
              }
              steps {
                  sh 'apt-get update' 
                  sh 'apt-get install -y --no-install-recommends curl'
                  sh 'rm -rf /var/lib/apt/lists/*'
              }
          }
          stage('Connect to server') {
              agent { docker { image 'node' } }
              steps {
                  sh 'curl http://localhost:8080'
              }
          }
      }
  }
  </code></pre>