0

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.

jhhwilliams
  • 1,357
  • 13
  • 22
  • What error you are getting on http://localhost? Is there any error in `docker logs CONTAINER` – Ash-Ishh.. Feb 27 '20 at 04:29
  • @Ash-Ishh.. Browsing to localhost returns _unable to connect_. Running `docker logs nginx` doesn't return anything, no. – jhhwilliams Feb 27 '20 at 04:40
  • The official nginx image on linux is port 8080 by default. Did you check and see if you are publishing the same port that nginx is running on? – OneLiner Feb 27 '20 at 06:21
  • @OneLiner In the default nginx.conf the server is set to listen on port 80. I'm guessing this is the Windows default. I've tried changing this value but it doesn't change the outcome. – jhhwilliams Feb 27 '20 at 06:29
  • Can you confirm on your host that docker process is occupying port 80 `netstat -tap` – Ash-Ishh.. Feb 27 '20 at 07:09
  • @Ash-Ishh.. running `netstat -tap` on my host returns no results. `docker ps` does however indicate `PORTS 0.0.0.0:80->80/tcp NAMES nginx` – jhhwilliams Feb 27 '20 at 07:19
  • Can you try docker inspect CONTAINER and also https://stackoverflow.com/a/23718720/4287377 might help in finding what process is running on which port – Ash-Ishh.. Feb 27 '20 at 07:51
  • @Ash-Ishh.. I believe that the container itself is OK. The problem is that inside the container, I cannot get nginx to start. – jhhwilliams Feb 27 '20 at 08:32

1 Answers1

1

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

dejdej
  • 2,590
  • 4
  • 16
  • 28
Mike-314
  • 331
  • 2
  • 6