我已将 python:3.8-slim-buster 映像部署到应用服务。通常它运行正确,因为我可以在日志中看到处理,但是健康检查机制尝试 ping 托管服务器但它没有响应,因为它只是在循环中运行并处理来自队列的消息的代码. 没问题,但应用程序因错误而被终止:
Container didn't respond to HTTP pings on port: 80, failing site start.
Stopping site because it failed during startup.
有没有办法删除此 Waiting for response to warmup request for container
或在 dockerfile 中指定以 OK 响应这些请求?
目前我的 dockerfile 是一个 2 liner,它只复制脚本然后运行 python 脚本。
复制而来的Dockerfile:
FROM python:3.8-slim-buster
COPY ./Scripts .
CMD [ "python3","-u","./calculate.py"]
第一步
在 Dockerfile 中添加 EXPOSE 8080
第 2 步
从 Dockerfile 构建镜像:
docker 构建。 -t python-计算器
第 3 步
docker images #search 带有你之前提到的标签的图像,即 python-calculator
第 4 步
docker 运行 -p 8080:8080 -d
第 5 步
本地主机:8080
解决方法是将脚本托管在服务器中,例如nodejs 或给定语言的等价物,或者创建单独的进程来为 80 端口返回一些东西。
默认配置的端口也可能有问题,这是如何解决这种情况的答案: https://serverfault.com/questions/1003418/azure-docker-app-error-site-did-not-start-within-expected-time-limit-and-co