Search code examples
azuredockernginxazure-web-app-serviceazure-container-service

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). Using Azure Container Registry for the same.

Here is my 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. ERROR - Container didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging

This is the docker run command available on App service logs

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. 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


Solution

  • Replaced

    FROM node:14.17.0 as build
    

    with

    FROM node:19-alpine as build
    

    Application was deployed successfully in Azure with success response. Usage of non alpine image caused the issue in Azure App Service.