Azure App Service Fails to Start w/ Azure Container Registry Pull – Docker Container – Can not Find File – Works with Docker Hub

Published

Problem :
Can not deploy Flask web application from Azure Container Registry even though I can deploy the same Docker image from Dockerhub and have it work. Logs indicate that app.py is unable to be found, but this file definitely in the root directory.

Additional Details
Pulling the image from Azure Container Registry and running it works on my local machine and on the machines of others who have tested it.

I have another web application with Node.JS that when run the exact same way (Click on Container Repo Tag X -> Deploy as App Service), it works.

Azure App Service seems to be able to pull the image. My password, username, and repo name are all correct in the docs.

Image has been built and deployed to via Azure DevOps, just like how my Node.JS web application was, which works fine. I also built the image locally and uploaded it to the Azure Container Registry and it also did not work.

Logs

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 <[email protected]>

#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 <[email protected]>

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" ]

Source: Docker Questions

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq