Docker容器无法在Azure应用服务中启动 [英] Docker Container fails to start in an Azure App Service

查看:62
本文介绍了Docker容器无法在Azure应用服务中启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,我在Azure App Services上发布了一堆Docker应用程序,但是由于某种原因,在Azure DevOps中创建新的构建和发布管道之后,我的Docker容器将无法在Azure App Service中运行.这些特定的容器具有Linux风格.

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.

在各种Docker映像之间切换,任何使用旧管道构建的镜像都可以,但是用新管道构建的镜像则不能.

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

当我将确切的命令从App Service的日志文件复制粘贴到我的本地命令行中时,它就可以正常工作.我可以使用与App Service相同的端口访问该网站.

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.

这是我的Dockerfile:

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}

推荐答案

虽然我不能确定是什么导致了您的问题,但可能是因为在容器中运行 ENTRYPOINT 命令时出错

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.

您是否正在使用 docker-compose.yml 文件?您的 COPY 命令不能包含 ../或当前目录之外的任何内容.为此,您需要通过 docker build 命令或 docker-compose.yml 文件更改上下文.

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.

我遇到了类似的问题,即我更改了 WORKDIR ,然后进行了 COPY..而不是将 WORKDIR 留在〜/并执行 COPY $ {STAGING_DIRECTORY}..

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

在Azure中,转到容器设置".在下面,您会看到一条日志.您可以使用此日志来确定您遇到的问题.

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.

它看起来像这样:

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

* _ default_docker.log 文件具有您的Docker文件弹出的错误,而 * __ docker.log 具有来自Azure的常规错误消息.

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

这篇关于Docker容器无法在Azure应用服务中启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆