Skip to content

chykman/dockerised-html-css-site

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

dockerised-html-css-site

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.

Features

  • Static HTML/CSS starter site using a clean layout and Google Fonts
  • Dockerfile based on nginx:alpine for a tiny runtime image
  • Simple to build and run for demos, tests, or teaching Docker basics

Prerequisites

  • Docker (Engine) installed and running. On Windows, Docker Desktop is the recommended option.

Build and run with Docker (recommended)

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-site

Then visit http://localhost:8080 in your browser.

Notes:

  • The image exposes port 80 (Nginx default); we map it to 8080 on the host in the example above to avoid needing elevated permissions.
  • Use --rm on docker run to remove the container when it stops.

Quick Docker Compose example

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

What the Dockerfile does

  • Uses the official nginx:alpine base image
  • Copies the contents of ./src into Nginx's default static folder (/usr/share/nginx/html)
  • Exposes port 80 and starts Nginx in the foreground

This makes the site available immediately from port 80 inside the container.

Development / preview without Docker

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

File structure

.
├─ Dockerfile            # builds an nginx image serving `src/`
├─ README.md
└─ src/
	 ├─ index.html
	 └─ style.css

Troubleshooting

  • If the container starts but you see a blank page, ensure the files are present under /usr/share/nginx/html inside 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 Dockerfile and the src/ folder with the site files.

License

This project is provided as-is for learning and demonstration purposes.


If you'd like, I can also:

  • add a docker-compose.yml file to the repo,
  • add a short CONTRIBUTING section or a license file,
  • run a quick docker build locally 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published