繁体   English   中英

Azure 应用服务无法启动 w/ Azure 容器注册表拉取 - Docker 容器 - 找不到文件 - 与 Docker 集线器一起使用

[英]Azure App Service Fails to Start w/ Azure Container Registry Pull - Docker Container - Can not Find File - Works with Docker Hub

问题:无法从 Azure Container Registry 部署 Flask web 应用程序,即使我可以从 Dockerhub 部署相同的 Docker 图像并让它工作。 日志显示找不到app.py,但是这个文件肯定在根目录下。

其他详细信息从 Azure Container Registry 拉取镜像并运行它可以在我的本地机器和其他测试过它的机器上运行。

我有另一个带有 Node.JS 的 web 应用程序,当以完全相同的方式运行时(单击 Container Repo Tag X -> Deploy as App Service),它可以工作。

Azure App Service好像可以拉取镜像。 我的密码、用户名和存储库名称在文档中都是正确的。

图像已通过 Azure DevOps 构建和部署,就像我的 Node.JS web 应用程序一样,运行良好。 我也在本地构建了镜像,上传到Azure Container Registry也没有用。

日志

2021-10-18T04:37:59 Welcome, you are now connected to log-streaming service.

Starting Log Tail -n 10 of existing logs ----

/home/LogFiles/__lastCheckTime.txt (https://capstonetest5.scm.azurewebsites.net/api/vfs/LogFiles/__lastCheckTime.txt)10/18/2021 04:31:54


/home/LogFiles/kudu/trace/6ba5fa616921-fc3f7bd3-b836-44a9-8d5d-600950059871.txt (https://capstonetest5.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/6ba5fa616921-fc3f7bd3-b836-44a9-8d5d-600950059871.txt)
2021-10-18T03:43:17 Startup Request, url: /api/vfs/site/wwwroot/?_=1634528185942, method: GET, type: request, pid: 69,1,5, ScmType: None

/home/LogFiles/kudu/trace/b3b774fbc187-7c732bb8-96d9-40e8-ad7f-1ea8613f4f67.txt (https://capstonetest5.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/b3b774fbc187-7c732bb8-96d9-40e8-ad7f-1ea8613f4f67.txt)
2021-10-18T03:47:38 Startup Request, url: /api/logs/docker, method: GET, type: request, pid: 66,1,14, ScmType: None

/home/LogFiles/kudu/trace/d761cf22f5fd-f24732b7-0784-497f-b9ad-33e2c9f6ed01.txt (https://capstonetest5.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/d761cf22f5fd-f24732b7-0784-497f-b9ad-33e2c9f6ed01.txt)
2021-10-18T03:46:22 Startup Request, url: /api/logs/docker, method: GET, type: request, pid: 75,1,6, ScmType: None

/home/LogFiles/2021_10_18_10-30-0-6_default_docker.log (https://capstonetest5.scm.azurewebsites.net/api/vfs/LogFiles/2021_10_18_10-30-0-6_default_docker.log)
2021-10-18T04:04:38.054254895Z python3: can't open file './app.py': [Errno 2] No such file or directory
2021-10-18T04:07:04.487934266Z python3: can't open file './app.py': [Errno 2] No such file or directory
2021-10-18T04:09:40.127878191Z python3: can't open file './app.py': [Errno 2] No such file or directory
2021-10-18T04:12:06.374547930Z python3: can't open file './app.py': [Errno 2] No such file or directory
2021-10-18T04:31:57.588787249Z python3: can't open file './app.py': [Errno 2] No such file or directory


/home/LogFiles/2021_10_18_10-30-0-6_docker.log (https://capstonetest5.scm.azurewebsites.net/api/vfs/LogFiles/2021_10_18_10-30-0-6_docker.log)
2021-10-18T04:31:55.398Z INFO - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2021-10-18T04:31:55.422Z INFO - Starting container for site
2021-10-18T04:31:55.424Z INFO - docker run -d -p 8016:5000 --name capstonetest5_0_9c0281eb -e DOCKER_CUSTOM_IMAGE_NAME=capstonefinal:103 -e PORT=5000 -e WEBSITES_PORT=5000 -e WEBSITE_SITE_NAME=capstonetest5 -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=capstonetest5.azurewebsites.net -e WEBSITE_INSTANCE_ID=8bae634d5da47ec1caf6ba245396aca0592deda150e06c87734fd81e9628db06 thylaw.azurecr.io/capstonefinal:103
2021-10-18T04:31:55.427Z INFO - Logging is not enabled for this container.Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2021-10-18T04:31:57.539Z INFO - Initiating warmup request to container capstonetest5_0_9c0281eb for site capstonetest5
2021-10-18T04:31:58.580Z ERROR - Container capstonetest5_0_9c0281eb for site capstonetest5 has exited, failing site start
2021-10-18T04:31:58.584Z ERROR - Container capstonetest5_0_9c0281eb didn't respond to HTTP pings on port: 5000, failing site start. See container logs for debugging.
2021-10-18T04:31:58.598Z INFO - Stopping site capstonetest5 because it failed during startup.

/home/LogFiles/webssh/.log (https://capstonetest5.scm.azurewebsites.net/api/vfs/LogFiles/webssh/.log)

Dockerfile

##Static layers

FROM alpine:3.7 AS skf-alpine37
MAINTAINER Glenn ten Cate <glenn.ten.cate@owasp.org>

#Installing needed binaries and deps. Then removing unneeded deps:
RUN apk update --no-cache && apk add python3 python3-dev py3-pip bash git dos2unix

#Dynamic layers
FROM skf-alpine37
MAINTAINER Glenn ten Cate <glenn.ten.cate@owasp.org>

RUN addgroup -g 1000 app
RUN adduser -u 1000 -G app -D -h /home/app app
RUN rm -rf /var/cache/apk/APKINDEX*

COPY ./ /home/app/XSS

#Switching to the new app location:
WORKDIR /home/app/XSS

RUN chown -R app:app /home/app/XSS

#Switching to the limited user
USER app

#Installing needed binaries and deps
RUN pip3 install --no-cache-dir --user -r requirements.txt

#Fixing Windows line endings for our students:
RUN find . -name ".sh" -o -name ".py" -o -name ".css" -o -name ".js" | xargs dos2unix

#Setting chmod +x on the scripts:
RUN find . -name ".sh" -o -name ".py" -o -name "Dockerfile" | xargs chmod +x

#Starting the actual application:
ENTRYPOINT [ "python3", "./app.py" ]

如果图像在您的本地计算机上工作,我建议您检查应用程序服务中配置下的应用程序设置。

尝试以下设置

  • WEBSITES_ENABLE_APP_SERVICE_STORAGE=false

我有一个 do.net 核心应用程序无法在 App Service 上运行,但是当我添加此环境变量时,它可以正常工作。 此变量表示您没有对容器使用持久卷。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM