Nginx on Windows in 5 minutes

Nginx on Windows in 5 minutes or less with Docker

Wait whaat? Nginx on Windows, who cares about that?? Actually many people do. Fortunately now is the greatest time to be a software engineer! Here is why.

I bet you heard about Docker in the past. If you didn’t then you probably living under a rock and you need to come out of there soon. Docker is slowly and surely removing boundaries between different OSes giving you reliable and consistent way to run SAME code on different platforms, whether it’s macOS, Linux or Windows.

There is more – at the recent DockerCon 2017 event Microsoft announced and showcased native support for containers running on Windows Server!

What does this tell us? Docker is here it stay, which is pretty exciting if you ask me.

Anyways, I promised to show you 5 minutes setup of Nginx for Windows so lets get back to that. Yes, I lied a little bit since you will need to install Docker on Windows first.

Now that the installation part is finished, lets move forward. Open your favorite Windows shell (cmd.exe) and type the following command:

docker run -d -p 80:80 --name nginx-test nginx`

At this point docker should start downloading Nginx container from Docker hub (if you don’t have it locally already). If everything goes smoothly, we should see something like this:

Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx

fdd5d7827f33: Pull complete
a3ed95caeb02: Pull complete
716f7a5f3082: Pull complete
7b10f03a0309: Pull complete
Digest: sha256:f6a001272d5d324c4c9f3f183e1b69e9e0ff12debeb7a092730d638c33e0de3e
Status: Downloaded newer image for nginx:latest

Once downloaded and started, open the browser and type “http://localhost” in there. Now hit enter, hold your breath and wait, in a few moments you should see awesome welcome page from Nginx:

nginx on windows welcome page

If you see the welcome page, that means your Nginx on Windows install is working (yay!) and you can start playing with it some more.

Next I would recommend to explore docker volumes. It will help us to mount dir with local Nginx configuration to the docker container. Then there is docker-compose which helps to create projects that can be easily shared between different people. The last option is to build new container from scratch.

As we increasingly rely on clouds and dynamic infrastructures (with autoscale and whatnot), we can’t just use static configurations as we used to. Modern container technologies, while simplifying some parts, often add yet additional twists and questions.. In the future I plan to cover Nginx for changing environments so make sure you sign up to my newsletter! and as usual I’m looking forward to your questions and comments below.

Wake up, Neo... The matrix has you...

Join our growing UNDERGROUND MOVEMENT of Rain Makers. Just drop your email below and your life will never be the same again.

Feel free to reach out on Twitter, Facebook or Instagram.

I won't send you spam. Unsubscribe at any time. Powered by ConvertKit

2 thoughts on “Nginx on Windows in 5 minutes or less with Docker”

  1. This post is not helpful. You are describing how to run a linux based docker image (nginx) on Windows. This is misleading because you are still running nginx in a linux environment which is inside of a VM on a windows machine.

    What about people who are running ACTUAL native Windows containers? The base image would have to be something like windows nano server and not some debian/linux base.

    You CAN run linux and windows images on a Windows 10 machine with the latest ‘Docker For Windows’ using an experimental feature that can be enabled to allow a true hybrid windows/linux docker environment. This would work for local testing but in production you would need 2 servers/cluster nodes to run linux and windows images.

    But none of this answers… How do you run nginx on a windows machine, which is running Docker For Windows in Windows Container mode?

  2. Below is what you get trying to run on an actual windows instance of Docker.

    c:\>docker run -d -p 80:80 –name nginx-test nginx
    Unable to find image ‘nginx:latest’ locally
    latest: Pulling from library/nginx
    docker: no matching manifest for windows/amd64 in the manifest list entries.
    See ‘docker run –help’.

Leave a Reply

Your email address will not be published. Required fields are marked *