A simple and attractive website hosted inside a Docker container using Nginx.
This project demonstrates how Docker can be used to containerize and deploy a static website. The website was built using HTML and CSS and then hosted inside an Nginx container.
The objective of this project was to understand Docker fundamentals, containerization, image creation, port mapping, and website deployment.
User Browser ↓ VM Public IP:8080 ↓ Docker Container ↓ Nginx Web Server ↓ HTML + CSS Website
- Docker
- Nginx
- HTML5
- CSS3
- Git
- GitHub
- Ubuntu Linux
docker-website-project/
│
├── Dockerfile
├── index.html
├── README.md
└── .gitignore
Docker is a containerization platform that packages an application along with its dependencies into lightweight and portable containers.
Benefits:
- Lightweight
- Fast deployment
- Portable
- Isolated environment
- Easy to scale
A container is an isolated environment where an application runs independently without affecting the host operating system.
In this project:
- Nginx runs inside the container.
- The website files are served by Nginx.
- Users access the website through the VM's public IP.
Create an HTML and CSS based website.
Use Nginx as the base image and copy the website into the Nginx directory.
Create a Docker image from the Dockerfile.
Launch a container and expose it to the outside world using port mapping.
Open the website in a browser using:
http://<VM_PUBLIC_IP>:8080
docker build -t mywebsite .docker run -d --name website-container -p 8080:80 mywebsitedocker psdocker logs website-containerdocker stop website-containerdocker start website-containerdocker rm -f website-containerVM Port 8080 ---> Container Port 80
When a user opens:
http://<VM_PUBLIC_IP>:8080
The request is forwarded to the Nginx web server running inside the Docker container.
ufw allow 8080/tcpAllow:
- Protocol: TCP
- Port: 8080
Through this project, I learned:
- Docker fundamentals
- Containerization concepts
- Docker image creation
- Dockerfile usage
- Nginx deployment
- Port mapping
- Linux commands
- Git and GitHub integration
- Website deployment inside containers
Project Implementation Screenshots
Figure 1: Infrastructure Setup
Figure 2: Firewall Configuration
Figure 3: NAT Configuration
Figure 4: Website Output
Chand Perveen
B.Tech Computer Science Engineering
Interested in:
- Cybersecurity
- Cloud Computing
- DevOps
- Infrastructure Monitoring