title: curl: (7) Failed to connect to localhost port 15672: Connection refused
body: <p>I want to use jenkins to run our testcases but our application has set of docker container which will get initiated when i run npm run deploy:</p>
  
  <p>problem: rabbitmq port is refused:localhost port 15672: Connection refused from inside the container while it is reachable outside the container.</p>
  
  <p>following are the current setup details:</p>
  
  <ol>
  <li><p>docker image from jenkins/jenkins:lts</p></li>
  <li><p>using dockerfile that will build the dependencies for jenkins that 
  also has  curl docker(docker inside docker),
  docker build will build image tagged by </p></li>
  <li><p><code>docker run --name myjenkins -u root -d -p 8080:8080 -p 50000:50000
  -v jenkins-data:/var/jenkins_home -v 
  /var/run/docker.sock:/var/run/docker.sock testSample</code></p>
  
  <pre><code>root@373d88dc52e5:/var/jenkins_home/workspace/pipelineDemo@script# curl http://localhost:15672
  curl: (7) Failed to connect to localhost port 15672: Connection refused
  </code></pre></li>
  <li><p>but when I use <code>--net=host</code> in docker run command as follows:</p>
  
  <pre><code>docker run --name myjenkins -u root -d -p 8080:8080 -p 50000:50000
  -v jenkins-data:/var/jenkins_home 
  /var/run/docker.sock:/var/run/docker.sock --net =host testSample
  </code></pre></li>
  </ol>
  
  <p>Rabbitmq is responding and I can run all my test cases </p>
  
  <p>but my project does not want me to use <code>--net=host</code> for security issues
  is there any other way such that i can reach rabbitmq and run testcases?</p>