my problem is the following
I created a jenkins container thanks to the following Dockerfile
# intall jenkins
FROM jenkins/jenkins:lts
# install python3.8.2 & dependancies
USER root
RUN apt-get update && apt-get -y install build-essential zlib1g-dev libncurses5-dev libgdbm-dev    libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
RUN curl -O https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz
RUN tar -xf Python-3.8.2.tar.xz
RUN cd Python-3.8.2 && pwd && ./configure && make -j 2 && make altinstall && python3.8 --version
RUN python3.8 -m pip install sklearn protobuf requests
# install docker
RUN curl -sSL https://get.docker.com/ | sh
My jenkins is running without problem on localhost:8080
In this jenkins I created a docker pipeline
pipeline{
    agent any
    stages{
            /*stage('retrieve docker images'){
                    steps{
                            sh 'docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD'
                            sh 'docker pull $model_name'
                    }
            }*/
            stage('create container model'){
                    steps{
                            sh 'docker run -d --name fugazi -t -p 3330:3330 $model_name'
                            sh 'sleep 5'
                    }
            }
            stage('use the model'){
                    steps{
                            sh 'python3.8 LaunchTestModel.py'
                    }
            }
            stage('remove docker stuff'){
                    steps{
                            sh 'docker stop fugazi'
                            sh 'docker rm fugazi'
                            sh 'docker rmi $model_name'
                    }
            }
    }
}
The first and second stages works well, they create a docker container reachable on localhost:3330. Then in third stage I try to communicate with this container, on localhost:3330 , thanks to LaunchTestModel.py.But at this point I receive a connexion refused error.
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=3330): Max retries exceeded with url: /model/methods/classify (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f492e79db80>: Failed to establish a new connection: [Errno 111] Connection refused'))
If I used LaunchTestModel.py outside jenkins it works well, it send data to localhost:3330 and receive an answer.
It seems that localhost:3330 is not reachable from inside the jenkins container ... So the question is how can I reach localhost:3330 from my jenkins container ? I'm not a docker expert and I searched a while before writing this post and what I think is that it is a matter of network between containers, I tried many things without success. Thanks for your help
