Serve static files in no time with NGINX and Docker

Docker example

Featured image

What is NGINX?

Initially it was just a webserver. Nowadays, it is often used as a reverse proxy, load balancer, and HTTP cache, static files server and more.

Serving static files

with docker, it is super simple. Just run:

docker run -it --rm -d -p 8080:80 nginx:1.23.3

and example index.html is served on localhost:8080.

Let’s look into it

docker exec -it CONTAINER_ID bash

example file is served in ./usr/share/nginx/html/index.html.

find . | grep index.html

and nginx config is in ./etc/nginx/nginx.conf

find . | grep nginx.conf