jhhwilliams
jhhwilliams

Reputation: 2582

Why is nginx not starting in Windows Server 2019 docker container?

UPDATE 3 (Solution):

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.

Original question:

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

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

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

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

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

UPDATE 1:

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.

UPDATE 2:

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

Exited (3221225785) 4 seconds ago

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

Upvotes: 0

Views: 4107

Answers (1)

Mike-314
Mike-314

Reputation: 351

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.

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

Upvotes: 3

Related Questions