Docker中的Blask应用没有加载更新的HTML
我已经将烧瓶应用程序包装到了Docker图像中。该应用程序根据后响应将新内容添加到现有的HTML(在烧瓶应用程序中渲染)。虽然HTML的新内容正确显示在我的本地上,但从Docker运行的应用程序仍显示旧内容。 我已经进行了检查,以确认已成功发送发布请求,并确认正在添加新内容。重新启动后,Docker容器在重新启动Docker容器时正确显示HTML的内容。
我怀疑该容器正在缓存HTML文件。构建Docker时是否有设置以不缓存HTML的内容?  
#start by pulling the python image
FROM python:3.6
ENV PYTHONUNBUFFERED True
#copy the requirements file into the image
COPY ./requirements.txt/app/requirements.txt
#switch working directory
WORKDIR /app
#install the dependencies and packages in the requirements file
RUN pip install -r requirements.txt
#copy every content from the local file to the image
COPY ./app
CMD exec gunicorn --bind 0.0.0.0:8000 --workers 1 --threads 8 --timeout 0 driver:app
I have containerized my flask app into a docker image. The application adds new content to an existing html (rendered in flask app) based on a POST response. While the new contents of html are displayed correctly on my local, app ran from docker still displays the old content. I have put in checks to confirm that POST request is successfully sent as well as to confirm that new contents are being added. Upon restart though, the docker container displays the contents of html correctly upon restarting the docker container.
I am suspecting that the container is caching html files. Is there a setting while building the docker to not cache the contents of html?
#start by pulling the python image
FROM python:3.6
ENV PYTHONUNBUFFERED True
#copy the requirements file into the image
COPY ./requirements.txt/app/requirements.txt
#switch working directory
WORKDIR /app
#install the dependencies and packages in the requirements file
RUN pip install -r requirements.txt
#copy every content from the local file to the image
COPY ./app
CMD exec gunicorn --bind 0.0.0.0:8000 --workers 1 --threads 8 --timeout 0 driver:app
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在下面添加代码
并在main()中调用它,如下面解决了问题
Adding the code below
and calling it inside main() like below solves the issue