This repository contains a dockerized static website (HTML, CSS, images)
served by Nginx.
It demonstrates how to package a website into a Docker image and share
it on Docker Hub.
├── index.html
├── about.html
├── error(404).html
├── styles/
├── images/
└── Dockerfile
The project uses the official lightweight nginx:alpine image.
FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY . /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]- Pulls the official lightweight Nginx server.
- Removes the default Nginx HTML files.
- Copies your website files into Nginx's web directory.
- Exposes port 80.
- Starts Nginx in the foreground.
Run this inside the project folder:
docker build -t mysite .Start the container:
docker run -d -p 8080:80 mysiteThen open in your browser:
http://localhost:8080
docker loginReplace YOUR_USERNAME with your Docker Hub username.
docker tag mysite YOUR_USERNAME/mysite:latestdocker push YOUR_USERNAME/mysite:latestdocker pull YOUR_USERNAME/mysite:latest
docker run -d -p 8080:80 YOUR_USERNAME/mysite:latestOpen:
http://localhost:8080- Start the container.
- Open a browser.
- Go to:
http://localhost:8080To stop:
docker ps
docker stop <container_id>This project demonstrates:
- Serving a static HTML/CSS website using Nginx\
- Packaging the site into a Docker image\
- Running it locally\
- Publishing it to Docker Hub\
- Letting others download and run it easily