I am trying to run a Flask API inside a Docker container. After running the container I get the following on terminal-
* Serving Flask app 'return-nlp' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://172.17.0.2:3000/ (Press CTRL C to quit)
On sending a POST request on the given URL, I don't get any response. I have also tried sending the same request to http://127.0.0.1:3000/, my own IP Address but I don't get any response from the container and get the two responses on Postman-
Error: connect ECONNREFUSED 127.0.0.1:3000
Error: connect ETIMEDOUT
CodePudding user response:
thanks to @KalusD. for suggesting using the -p
option to publish the port on the host machine, this seems to have solved the issue.
we use the -p
option to bind the port from the process running in the container to the port on the host machine
--publish , -p Publish a container's port(s) to the host
Check here for more info from the official docs.