为什么Nginx无法在Windows Server 2019 Docker容器中启动? [英] Why is nginx not starting in Windows Server 2019 docker container?

查看:622
本文介绍了为什么Nginx无法在Windows Server 2019 Docker容器中启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新3(解决方案):

我在主机上安装了最新的Windows更新,并指定了确切的servercore映像以匹配更新的Windows Server版本:

I installed the latest Windows updates on my host and specified the exact servercore image to match my updated Windows Server version:

mcr.microsoft.com/windows/servercore:10.0.17763.973

运行容器时,一切正常.

When running the container everything worked as expected.

原始问题:

我无法弄清楚为什么 nginx 不能在我运行的容器中启动Windows Server 2019.

I cannot figure out why nginx doesn't start in my container running on Windows Server 2019.

没有任何内容写入nginx error.log,也没有使用此答案检查系统事件,但未提供任何信息关于nginx.

Nothing is written to the nginx error.log and inspecting the System Event using this answer doesn't provide any information regarding nginx.

当我直接在服务器上运行nginx时(即没有容器),它会正常启动.

When I run nginx directly on the server (i.e. without the container) it starts up fine.

以下是dockerfile的内容:

Here are the contents of the dockerfile:

FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR C:/nginx
COPY /. ./
CMD ["nginx"]

我使用以下命令运行容器:

I run the container using the following command:

docker run -d --rm -p 80:80 --name nginx `
-v C:/Data/_config/nginx/conf:C:/nginx/conf `
-v C:/Data/_config/nginx/temp:C:/nginx/temp `
-v C:/Data/_config/nginx/logs:C:/nginx/logs `
nginx-2019

如果我exec进入正在运行的容器,则可以看到目录结构符合预期:

If I exec into the running container I can see that the directory structure is as expected:

Microsoft Windows [Version 10.0.17763.1040]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\nginx>dir
 Volume in drive C has no label.
 Volume Serial Number is 72BD-907D

 Directory of C:\nginx

02/27/2020  06:05 AM    <DIR>          .
02/27/2020  06:05 AM    <DIR>          ..
02/27/2020  06:05 AM    <DIR>          conf
02/27/2020  05:11 AM    <DIR>          contrib
02/27/2020  05:11 AM    <DIR>          docs
02/27/2020  05:11 AM    <DIR>          html
02/27/2020  05:55 AM    <DIR>          logs
02/27/2020  05:14 AM    <DIR>          conf
01/21/2020  03:30 PM         3,712,512 nginx.exe
01/21/2020  04:41 PM    <DIR>          temp
               1 File(s)      3,716,608 bytes
               9 Dir(s)  21,206,409,216 bytes free

更新1:

作为故障排除过程的一部分,我在Azure上启动了一个干净的VM,并在安装Docker并使用完全相同的文件重新创建Docker映像后,它按预期启动.

As part of my troubleshooting process I started up a clean VM on Azure and after installing Docker and recreating the Docker image using the exact same files, it starts up as expected.

这意味着该问题是我的服务器所特有的,而不是一般性问题.

This means that the issue is specific to my server and not a general issue.

更新2:

通过从运行命令中删除--rm,我在容器退出后通过运行docker ps -a找到了以下信息:

By removing the --rm from the run command I find the following info by running docker ps -a after the container exits:

4秒钟前退出(3221225785)

Exited (3221225785) 4 seconds ago

我找不到有关退出代码含义的任何信息.

I can't find any info on what the exit code means.

推荐答案

我遇到了同样的问题,但对我来说,它不是docker或nginx,而是镜像. 图像mcr.microsoft.com/windows/servercore:ltsc2019已于2020年2月11日更新,容器和主机都必须具有相同的更新(我认为是KB4532691),否则某些进程可能会静默失败.

I was having the same issue, but for me it wasn't docker or nginx, it was the image. image mcr.microsoft.com/windows/servercore:ltsc2019 was updated on 2/11/2020 and both container and host must have the same update (KB4532691 I think) or some processes may fail silently.

我更新了主机,一切正常.

I updated my host, and all is well.

请参见 microsoft-windows-servercore

See microsoft-windows-servercore and you-might-encounter-issues-when-using-windows-server-containers-with-t for more info

这篇关于为什么Nginx无法在Windows Server 2019 Docker容器中启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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