I tried using flask with docker. I can run my container without errors but when i tried to connect to it on the browser i get 404 not found error:
Browser error
And my container console:
container cons
To be clear, when i run flask on my machine the app work perfectly. The error is only when i use docker.
Here is a sample of my flask app:
from flask import Flask, redirect, render_template, render_template_string, request, url_for
from api import fetch_inventory
app = Flask(__name__)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000, debug=True)
@app.route('/')
def home_page():
return render_template('home/index.html')
And my DockerFile
FROM python:3.9-slim
WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
CMD ["python", "flaskApp.py"]
I build the image using the command: docker build --no-cache -t <image name>
And i start the container using: docker container run -d -p 8000:8000 <image name>
Thx for the help 🙂
3