I have a simple Flask application that just outputs "Hello world". If I do something like flask run --host=127.0.0.23 --port=5001 on my host machine, I can ping the app on my browser on the given hostname and port.
However, if I do the same thing when running this app inside a Docker container i.e. I have
CMD flask run --host=127.0.0.23 --port=5001 inside my Dockerfile, I cannot ping the application on my host machines browser.
I understand that having app.run(host='0.0.0.0') inside the Flask app makes it accessible at localhost:5000 on my host machine. But I want to know if I can access the app using a hostname I assign myself.
Code for Flask application:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World"
if __name__ == "__main__":
app.run(host="0.0.0.0")