1

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:

problem: rabbitmq port is refused:localhost port 15672: Connection refused from inside the container while it is reachable outside the container.

following are the current setup details:

  1. docker image from jenkins/jenkins:lts

  2. using dockerfile that will build the dependencies for jenkins that also has curl docker(docker inside docker), docker build will build image tagged by

  3. 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

    root@373d88dc52e5:/var/jenkins_home/workspace/pipelineDemo@script# curl http://localhost:15672
    curl: (7) Failed to connect to localhost port 15672: Connection refused
    
  4. but when I use --net=host in docker run command as follows:

    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
    

Rabbitmq is responding and I can run all my test cases

but my project does not want me to use --net=host for security issues is there any other way such that i can reach rabbitmq and run testcases?

tgogos
  • 23,218
  • 20
  • 96
  • 128
vm31
  • 169
  • 1
  • 4
  • 15
  • There's many methods you can use, see https://stackoverflow.com/questions/17770902/forward-host-port-to-docker-container – nos Sep 18 '18 at 08:21

0 Answers0