Introduction
This is also another article which is involving Docker tool. Specifically, the usage of Docker tool with the help of the existence of Docker Desktop service. In this context, a running Docker Desktop service in a local device using Microsoft Windows as its operating system. In order to install Docker Desktop in Microsoft Windows, just refer to ‘How to Install Docker Desktop in Microsoft Windows‘. So, after installing Docker Desktop, just make sure that the service is running. After checking the Docker Desktop service is running, just try to execute the docker command as in ‘How to Execute Docker Command in Microsoft Windows‘.
How to Run Nginx using Docker Container in Microsoft Windows
After that, just follow all the steps below. Those are steps in order to run Nginx using docker container in a local device running using Microsoft Windows as the operating system :
-
So, first of all, just execute the command line interface. For an example, in this context as an example, it is a Command Prompt. Below is the appearance of the Command Prompt :
Microsoft Windows [Version 10.0.22000.1219] (c) Microsoft Corporation. All rights reserved. C:\Users\Personal
-
Continue on the step, just execute the following command :
C:\Users\Personal>docker run -d -p 8181:80 --name web1 --restart=always nginx:latest Unable to find image 'nginx:latest' locally latest: Pulling from library/nginx 025c56f98b67: Pull complete ec0f5d052824: Pull complete cc9fb8360807: Pull complete defc9ba04d7c: Pull complete 885556963dad: Pull complete f12443e5c9f7: Pull complete Digest: sha256:75263be7e5846fc69cb6c42553ff9c93d653d769b94917dbda71d42d3f3c00d3 Status: Downloaded newer image for nginx:latest d8fc06dd81a53afd3ffe8e60e24b930e9a15d6a584e1f28542c6c15efe841d0e C:\Users\Personal>
So, the command parameter of ‘docker’ in this context is ‘run’. Is is an additional command parameter to run a docker container. In this context, it will use port 8181 as the service port for access which representing port 80 in the docker container. Since maybe in the host or the device where the docker container run will be another service which has already run in port 80. So, it is wise to use an unused port. Furthermore, the docker container will have the name as it is specified in the ‘-name’ parameter which is ‘web1’. As an additional parameter, it will specify ‘-restart=always’ which means that the service will automatically restart upon the restart of Docker Desktop service. Last but not least which is also an important parameter is the ‘nginx:latest’. It means, the docker container will use a docker image with the name of ‘nginx’ with the latest version. Since the docker image is not exist in the local device, it is automatically pulled from the public docker repository.
-
Next, after the docker container is running, just execute the following command to check the status of the docker container which is running using ‘nginx’ docker image :
C:\Users\Personal>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d8fc06dd81a5 nginx:latest "/docker-entrypoint.…" 36 seconds ago Up 34 seconds 0.0.0.0:8181->80/tcp web1 C:\Users\Personal>
-
Finally, in the last step, just to make sure the docker container running properly, access ‘localhost:8181’ in the local device to check whether the Nginx Webserver is successfully running or not. Below is the appearance of the Nginx Webserver :
How to Run Nginx using Docker Container in Microsoft Windows