Introduction
This is another article where the main focus is just to be able to show how to execute docker command. In this context, it is focusing in how to add a new HTML file. Just add the HTML file to the running Nginx webserver and then display it further. In this case, it is running the docker container using the help of Docker Desktop service in a local device. Furthermore, that local device is using Microsoft Windows as its operating system. Actually, this article is the continuation from the previous article. In the previous article ‘How to Run Nginx using Docker Container in Microsoft Windows‘, it is just focusing on how to run Nginx webserver in a docker container in the local device running using Microsoft Windows. After that, the continuation of the process in this article will show how to add a new HTML file. The main purpose is for showing that new HTML file. It is showing via Nginx Webserver which is currently running in the docker container.
How to Execute Docker Command to Add New HTML File and Access it via Nginx Docker Container in Microsoft Windows
So, after confirming that the docker container is running properly, just perform several steps below for achieving that purpose :
-
First of all, just check the docker container by running the following command :
C:\Users\Personal>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b0c5e028c40d registry "/entrypoint.sh /etc…" 2 days ago Up 12 seconds 0.0.0.0:5000->5000/tcp hub.local d8fc06dd81a5 nginx:latest "/docker-entrypoint.…" 2 days ago Up 12 seconds 0.0.0.0:8181->80/tcp web1 C:\Users\Personal>
-
Since the docker container is actually exist and currently running, use it futher. In order to use it, just refer to the name of the docker container which is ‘web1’. Use it to perform a command execution in order to get in to the docker container and execute the bash command as follows :
C:\Users\Personal>docker exec -it web1 bash root@d8fc06dd81a5:/#
-
Continue on the above step, just execute the following command to fill a specific string into a file with the name of ‘hello.html’ as an example below :
root@d8fc06dd81a5:/# echo "<h2>Hello, Welcome</h2>" > hello.html root@d8fc06dd81a5:/#
-
Following after, just move the ‘hello.html’ file into the main document root of the Nginx webserver as follows :
root@d8fc06dd81a5:/# mv hello.html /usr/share/nginx/html/ root@d8fc06dd81a5:/#
-
And after that, just get out from the bash command inside the docker container by typing ‘exit’ as it appear below :
root@d8fc06dd81a5:/# exit exit C:\Users\Personal>
-
Finally, in order to confirm the existence of the file with the name of ”hello.html’ just execute the address ‘localhost:8181/hello.html’ as follows :
How to Execute Docker Command to Add New HTML File and Access it via Nginx Docker Container in Microsoft Windows