简体   繁体   English

在 Azure App Service 上部署 dockerized 图像后应用程序运行失败

[英]Application run failed after deploying dockerized image on Azure App Service

I am trying to deploy dockerized React JS application (uses ngnix) on MS Azure App Service (Web application as Container/Web App).我正在尝试在 MS Azure 应用服务(Web 应用程序作为容器/Web 应用程序)上部署 dockerized React JS 应用程序(使用 ngnix)。 Using Azure Container Registry for the same.同样使用 Azure 容器注册表。

Here is my Dockerfile这是我的 Dockerfile

FROM node:14.17.0 as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./

RUN npm ci --silent
RUN npm install react-scripts -g --silent
COPY . .
RUN npm run build 

#prepare nginx
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html

#fire up nginx
EXPOSE 80
CMD ["nginx","-g","daemon off;"]

Able to run image as container on local machine and working perfectly.能够在本地机器上将图像作为容器运行并完美运行。

docker run -itd --name=ui-container -p 80:80 abc.azurecr.io:latest

But problem starts after running the image on Azure App Service/ Container Service due to it is not able to ping the port.但是在 Azure App Service/Container Service 上运行图像后问题开始了,因为它无法 ping 通端口。 ERROR - Container didn't respond to HTTP pings on port: 80, failing site start.错误 - 容器未响应端口 80 上的 HTTP ping,站点启动失败。 See container logs for debugging查看容器日志进行调试

This is the docker run command available on App service logs这是应用程序服务日志上可用的 docker run 命令

docker run -d --expose=80 --name id_0_f8823503 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITES_PORT=80 -e WEBSITE_SITE_NAME=id -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=id.azurewebsites.net -e WEBSITE_INSTANCE_ID=af26eeb17400cdb1a96c545117762d0fdf33cf24e01fb4ee2581eb015d557e50 -e WEBSITE_USE_DIAGNOSTIC_SERVER=False i.azurecr.io/ivoyant-datamapper

I see the reason is there is no -p 80:80 found in above docker run command.我知道原因是在上面的 docker run 命令中没有找到 -p 80:80 。 I have tried multiple approaches to fix this but nothing worked for me.我尝试了多种方法来解决这个问题,但对我没有任何帮助。 Tried adding key: PORT value: 80 in configuration app settings key: WEBSITES_PORT value: 80 in configuration app settings尝试添加密钥:PORT 值:配置应用程序设置中的 80 密钥:WEBSITES_PORT 值:配置应用程序设置中的 80

App Service listens on port 80/443 and forwards traffic to your container on port 80 by default.默认情况下,应用服务侦听端口 80/443 并将流量转发到端口 80 上的容器。 If your container is listening on port 80, no need to set the WEBSITES_PORT application setting.如果您的容器正在侦听端口 80,则无需设置WEBSITES_PORT应用程序设置。 The -p 80:80 parameter is not needed.不需要-p 80:80参数。

You would set WEBSITES_PORT to the port number of your container only if it listens on a different port number.只有当它侦听不同的端口号时,您才可以将WEBSITES_PORT设置为容器的端口号。

Now, why does App Service reports that error?现在,为什么 App Service 会报告该错误? It might be that your app fails when starting.可能是您的应用程序在启动时失败。 Try enabling the application logs to see if you'll get more info.尝试启用应用程序日志以查看您是否会获得更多信息。

Replaced已更换

FROM node:14.17.0 as build

with

FROM node:19-alpine as build

Application was deployed successfully in Azure with success response.应用程序已在 Azure 中成功部署并获得成功响应。 Usage of non alpine image caused the issue in Azure App Service.使用非高山图像导致 Azure 应用服务出现问题。

暂无
暂无

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

相关问题 将角度应用程序部署到Azure门户网站Web应用程序后如何解决“无法加载资源404” - How to fix “Failed to load resource 404” after deploying angular application to azure portal web app HTTP错误502.3-在Azure Tomcat应用程序服务中部署Spring Boot应用程序后,网关错误 - HTTP Error 502.3 - Bad Gateway when after deploying Spring boot application in azure tomcat app service 部署 Django 并将应用程序反应到 Azure 应用程序服务后的下一步 - next steps after deploying Django and react app to Azure app service Azure 应用服务在部署 REACT JS 应用程序时出错 - Azure App Service Getting error while deploying REACT JS application 使用 MSDeploy 将 web 应用程序部署到 Azure App Service - Deploying a web application to an Azure App Service using MSDeploy 部署到Azure App Service时缺少Application Insights DLL - Missing Application Insights DLL when deploying to Azure App Service 将节点 js 应用程序部署到 MS azure 服务后出错 - Error after deploying node js app to MS azure service 将Springboot部署到Azure App Service - Deploying Springboot to Azure App Service 手动将 Angular 应用部署到 Azure 应用服务 - Manually deploying angular app to Azure App Service 错误:部署失败:从 Azure DevOps 服务部署到应用服务时出现 ERROR_DESTINATION_NOT_REACHABLE - Error: Deployment failed: ERROR_DESTINATION_NOT_REACHABLE when deploying to App Service from Azure DevOps Services
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM