Nginx is an opensource high performance and low memory usage reverse proxy for HTTP, HTTPS, POP3, SMTP, and IMAP protocols. It can be used as a load balancer, reverse proxy for other webserver or service or directly as an HTTP server.
In this tutorial, I will show you how to run a local HTTP server to serve your static website without installing anything on your machine, using only Docker.
What you will need: a computer with Docker installed, preferably running Ubuntu (or any Linux distribution) and some basic docker knowledge. Don’t forget to prepare a static HTML page or a whole website.
index.html
<!DOCTYPE html>
<html>
<body>
<h1>My Awesome static page</h1>
<p>My first paragraph about it.</p>
</body>
</html>
The above file will be our testing static page that will be served by Nginx. You can use anything you want, even a whole static website. You can run a simple docker Nginx image by typing docker run --name my-nginx -d nginx
, but we want to forward its 80
port to our machine’s 80
port. So, we are gonna run a Nginx container with the following arguments:
docker run --name my-nginx -p 80:80 -v /[your-path]/my-website:/usr/share/nginx/html:ro -d nginx
You can test if it works in your browser, browsing the localhost address.

Also, to list all running docker containers:
docker ps
To stop it:
docker stop my-nginx
To remove the image:
docker rm my-nginx