A minimal example static website served by an Nginx Docker image.
This repository contains a small HTML/CSS site in src/ and a Dockerfile
that copies the site into an Nginx image so you can build and run it locally
inside a container.
- Static HTML/CSS starter site using a clean layout and Google Fonts
- Dockerfile based on
nginx:alpinefor a tiny runtime image - Simple to build and run for demos, tests, or teaching Docker basics
- Docker (Engine) installed and running. On Windows, Docker Desktop is the recommended option.
From the repository root (where the Dockerfile lives) run:
docker build -t dockerised-html-css-site .
docker run --rm -p 8080:80 dockerised-html-css-siteThen visit http://localhost:8080 in your browser.
Notes:
- The image exposes port
80(Nginx default); we map it to8080on the host in the example above to avoid needing elevated permissions. - Use
--rmondocker runto remove the container when it stops.
Create a docker-compose.yml with the following to run the site via Compose:
version: '3.8'
services:
web:
build: .
ports:
- "8080:80"Then run:
docker compose up --build- Uses the official
nginx:alpinebase image - Copies the contents of
./srcinto Nginx's default static folder (/usr/share/nginx/html) - Exposes port
80and starts Nginx in the foreground
This makes the site available immediately from port 80 inside the container.
You can preview the site locally by opening src/index.html in your
browser. For a local static server (recommended) you can use Python's
built-in server from the src directory:
# from repository root
cd src
python -m http.server 8000
# then open http://localhost:8000.
├─ Dockerfile # builds an nginx image serving `src/`
├─ README.md
└─ src/
├─ index.html
└─ style.css
- If the container starts but you see a blank page, ensure the files are
present under
/usr/share/nginx/htmlinside the container. You can inspect a running container:
docker ps # get container id
docker exec -it <id> ls -la /usr/share/nginx/html- If Docker build fails, check that the working directory contains the
Dockerfileand thesrc/folder with the site files.
This project is provided as-is for learning and demonstration purposes.
If you'd like, I can also:
- add a
docker-compose.ymlfile to the repo, - add a short CONTRIBUTING section or a license file,
- run a quick
docker buildlocally to validate the instructions (I can do that now if you want me to try building in this environment).
Let me know which of the above you'd like next.