'Dockerized Flask application partly loading pictures

I currently have a Docker container running with a Flask app. This Flask app is running a simple website that uses images. These images are loaded via the flask typical static folder.

app = Flask(__name__, static_folder='static', static_url_path='/')

But when this page is called while running in the container, images sometimes take forever to load for no apparent reason. They are displayed on the web page, but the loading icon does not disappear and when you cancel the loading, the image disappears and the "alt" text appears.

Even converting the images to WebP didn't help. The Flask server is running with an SSL certificate (could be an important information).

app.run(host="0.0.0.0", port=443, ssl_context=('fullchain.pem', 'privkey.pem'))

The pictures are implemented in HTML with:

<img src="/picture.webp" alt="picture">

My Dockerfile looks like that:

FROM python:3.9

WORKDIR /
COPY . .

RUN pip install -r requirements.txt

ENTRYPOINT ["python"]
CMD ["app.py"]

And my requirements.txt: flask

Buliding the docker with: docker build /path/to/dockerfile -t app

and running: docker run -d -p 443:443 --restart=always app

I hope some of you can help me. Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source