Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

local-web

Run a lightweight nginx web server in Docker, using any local directory as the document root. Launch multiple instances at once, each on its own port.

Prerequisites

Quick start

# Build the image (optional — the launcher builds automatically on first run)
.\local-web.ps1 build

# Serve a folder on port 8080
.\local-web.ps1 start -Directory "C:\path\to\your\site" -Port 8080

# Serve a subfolder on a different port
.\local-web.ps1 start -Directory "C:\path\to\your\site\public" -Port 8081

# Open http://localhost:8080 in your browser

On Linux/macOS/WSL:

chmod +x local-web.sh
./local-web.sh start --directory /path/to/your/site --port 8080

Commands

Command Description
start Mount a directory and serve it on the given port (default 8080)
stop Stop and remove the container for a port
list Show running local-web containers
build Build the Docker image manually

PowerShell

.\local-web.ps1 start -Directory "C:\sites\demo" -Port 3000
.\local-web.ps1 stop  -Port 3000
.\local-web.ps1 list

Bash

./local-web.sh start -d /sites/demo -p 3000
./local-web.sh stop -p 3000
./local-web.sh list

How it works

  • Each instance runs nginx as a web server in a lightweight Alpine container.
  • The directory you pass becomes the document root (/usr/share/nginx/html inside the container).
  • Requests are handled like a normal website: / serves index.html, paths map to files under the root.
  • The host port maps to port 80 inside the container.
  • Container names follow the pattern local-web-<port> so you can run many at once.

Notes

  • The path you pass is exactly what gets served — pass a subfolder path directly if you only want that part of a tree.
  • On Windows, use absolute paths (e.g. C:\Users\...). Docker Desktop must have file sharing enabled for that drive.
  • Changes to files on disk are reflected immediately (no rebuild needed); refresh the browser to see updates.

About

Docker nginx web server that serves a local directory as its document root

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages