Docker Container fails to start in an Azure App Service

不问归期 提交于 2021-01-29 08:29:21

问题


I've released a bunch of Docker apps on Azure App Services in the past, but for some reason, after creating a new build and release pipeline in Azure DevOps, my Docker containers won't run in an Azure App Service. These particular containers are on the Linux flavor.

Switching between various Docker images, any built with the old pipeline work, but ones built with the new pipeline do not.

When I copy-paste the exact command from the App Service's log file into my local command line, it works just fine. I'm able to access the site as the same port as the App Service.

Here is my Dockerfile:

FROM node:8.12.0-alpine

ARG BUILD_VERSION
ENV BUILD_VERSION ${BUILD_VERSION}

ENV LOCAL_DEVELOPMENT false
ENV NODE_ENV production

ARG STAGING_DIRECTORY

WORKDIR ~/
COPY ${STAGING_DIRECTORY} .

ENTRYPOINT node . server ${BUILD_VERSION}

回答1:


While I can't say for sure what's causing your issue, it's probably because there's an error running the ENTRYPOINT command in your container.

Is it possible you're using a docker-compose.yml file? Your COPY command can't have ../ or anything outside of the current directory. To do this, you'll want to change the context via either your docker build command or the docker-compose.yml file.


I had a similar issue where I was changing the WORKDIR and then doing a COPY . . instead of leaving WORKDIR at ~/ and doing COPY ${STAGING_DIRECTORY} ..

In Azure, go to your "Container settings". Down below, you'll see a log. You can use this log to determine the issue you're having.

It will look something like this:

2018_10_16_RD00155DFE4342_default_docker.log:
2018-10-16T16:14:33.084558195Z     throw err;
2018-10-16T16:14:33.084568395Z     ^
2018-10-16T16:14:33.084576596Z 
2018-10-16T16:14:33.084584396Z Error: Cannot find module '/home/vsts/work/1/a/publish'
2018-10-16T16:14:33.084592096Z     at Function.Module._resolveFilename (module.js:548:15)
2018-10-16T16:14:33.084599797Z     at Function.Module._load (module.js:475:25)
2018-10-16T16:14:33.084607297Z     at Function.Module.runMain (module.js:694:10)
2018-10-16T16:14:33.084614697Z     at startup (bootstrap_node.js:204:16)
2018-10-16T16:14:33.084622297Z     at bootstrap_node.js:625:3

2018_10_16_RD00155DFE4342_docker.log:

2018-10-16 16:14:01.928 ERROR - Container [CONTAINER_NAME] for site [APP_SERVICE_NAME] has exited, failing site start
2018-10-16 16:14:27.665 INFO  - Starting container for site
2018-10-16 16:14:27.666 INFO  - docker run -d -p 26257:80 --name [CONTAINER_NAME] -e DOCKER_CUSTOM_IMAGE_NAME=[...]

2018-10-16 16:14:29.735 ERROR - Container [CONTAINER_NAME] for site [APP_SERVICE_NAME] has exited, failing site start
2018-10-16 16:14:31.998 INFO  - Starting container for site
2018-10-16 16:14:31.999 INFO  - docker run -d -p 3225:80 --name [CONTAINER_NAME] -e DOCKER_CUSTOM_IMAGE_NAME=[...]

2018-10-16 16:14:34.009 ERROR - Container [CONTAINER_NAME] for site [APP_SERVICE_NAME] has exited, failing site start

The *_default_docker.log file has the error your Docker file spouts while *_docker.log has the generic error message from Azure.



来源:https://stackoverflow.com/questions/52850254/docker-container-fails-to-start-in-an-azure-app-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!