this is about a simple flask-restplus microservice with an echo endpoint, that can be found here that runs locally by default on port 5000:
cd $src_folder
python app.py
but when running in a docker container with a simple Dockerfile...
RUN pip install --no-cache-dir -r requirements.txt
CMD [ "python", "./app.py" ]
...with the correct port mapping/exposing, it is not reachable for some reason:
docker run -d -h $HOST --name $CONTAINER \
--publish $SERVER_PORT:$CONTAINER_PORT $DOCKER_HUB_IMG:$IMAGE_VERSION
...even if the container logs are telling that it has started correctly:
(venv) .../flaskexample$ docker logs flaskexample
2017-09-17 18:23:12,505 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2017-09-17 18:23:12,506 - werkzeug - INFO - * Restarting with stat
2017-09-17 18:23:13,016 - werkzeug - WARNING - * Debugger is active!
2017-09-17 18:23:13,021 - werkzeug - INFO - * Debugger PIN: 246-320-471
(venv) .../flaskexample$
...and also looking ok in docker ps:
(venv) .../flaskexample$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d90da7ae192 kakicode/flaskexample:latest "python ./app.py" 4 minutes ago Up 4 minutes 0.0.0.0:5000->5000/tcp flaskexample
..but for some reason I keep getting:
...and I am running out of ideas...have to say that I am not providing the SERVER_NAME in flask-restplus configuration, as it does not make any difference, still getting the same issue, and also that every other container requiring port mapping/exposing works fine in my docker daemon. I am running these experiment in Ubuntu 14.04.5.
...has anyone experienced anything similar with flask-restplus out there?
thanking you all in advance
Your issue is that you would have used something like below in your app.py
or just
What this does is listens on
127.0.0.1
by default. But for port mapping to work it has to listen on all interfaces inside the container. So you should be usingFor further reference see:
http://flask.pocoo.org/docs/0.12/api/?highlight=run#flask.Flask.run