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.
- Docker Desktop (Windows/macOS) or Docker Engine (Linux)
# 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 browserOn Linux/macOS/WSL:
chmod +x local-web.sh
./local-web.sh start --directory /path/to/your/site --port 8080| 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 |
.\local-web.ps1 start -Directory "C:\sites\demo" -Port 3000
.\local-web.ps1 stop -Port 3000
.\local-web.ps1 list./local-web.sh start -d /sites/demo -p 3000
./local-web.sh stop -p 3000
./local-web.sh list- Each instance runs nginx as a web server in a lightweight Alpine container.
- The directory you pass becomes the document root (
/usr/share/nginx/htmlinside the container). - Requests are handled like a normal website:
/servesindex.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.
- 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.