A simple web server deployed inside a Docker container using Nginx.
This project demonstrates the basics of Docker containerization by deploying a custom HTML web page through an Nginx web server running inside a Docker container.
- Docker
- Dockerfile
- Nginx
- HTML
- PowerShell
- Git & GitHub
CodeAlpha_DockerWebServer/
├── Dockerfile
├── .dockerignore
├── index.html
└── README.md
The Dockerfile uses the lightweight nginx:alpine image as the base image and copies the custom index.html into Nginx's default web directory.
docker build -t codealpha-webserver .docker run -d -p 8080:80 --name codealpha-webserver-container codealpha-webserverThe web server can then be accessed at:
http://localhost:8080
docker psdocker stop codealpha-webserver-containerdocker start codealpha-webserver-containerdocker restart codealpha-webserver-containerdocker ps -adocker rm codealpha-webserver-containerdocker logs codealpha-webserver-containerdocker stats codealpha-webserver-container --no-streamdocker exec codealpha-webserver-container nginx -tdocker inspect codealpha-webserver-containerThe Docker container runs Nginx on port 80.
The host machine exposes the web server through port 8080.
Host: 8080
↓
Container: 80
↓
Nginx
↓
index.html
- Used a lightweight Nginx Alpine image.
- Created a custom Dockerfile instead of manually configuring a container.
- Used
.dockerignoreto exclude unnecessary files from the Docker build context. - Used a descriptive image and container name.
- Documented container lifecycle and troubleshooting commands.
- Verified the Nginx configuration from inside the running container.
The web server was successfully containerized using Docker and deployed through Nginx. The container lifecycle, monitoring, configuration validation, and troubleshooting commands were also tested successfully.