Skip to content

About

A Dockerized Nginx web server demonstrating containerization, deployment, lifecycle management, monitoring, and troubleshooting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeAlpha Docker Web Server

A simple web server deployed inside a Docker container using Nginx.

Project Objective

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.

Technologies Used

  • Docker
  • Dockerfile
  • Nginx
  • HTML
  • PowerShell
  • Git & GitHub

Project Structure

CodeAlpha_DockerWebServer/
├── Dockerfile
├── .dockerignore
├── index.html
└── README.md

Dockerfile

The Dockerfile uses the lightweight nginx:alpine image as the base image and copies the custom index.html into Nginx's default web directory.

Build the Docker Image

docker build -t codealpha-webserver .

Run the Container

docker run -d -p 8080:80 --name codealpha-webserver-container codealpha-webserver

The web server can then be accessed at:

http://localhost:8080

Container Lifecycle Commands

Check running containers

docker ps

Stop the container

docker stop codealpha-webserver-container

Start the container

docker start codealpha-webserver-container

Restart the container

docker restart codealpha-webserver-container

View all containers

docker ps -a

Remove the container

docker rm codealpha-webserver-container

Monitoring and Troubleshooting

View container logs

docker logs codealpha-webserver-container

Monitor resource usage

docker stats codealpha-webserver-container --no-stream

Test Nginx configuration

docker exec codealpha-webserver-container nginx -t

Inspect container configuration

docker inspect codealpha-webserver-container

Port Mapping

The Docker container runs Nginx on port 80.

The host machine exposes the web server through port 8080.

Host:      8080
              ↓
Container: 80
              ↓
           Nginx
              ↓
         index.html

Best Practices Demonstrated

  • Used a lightweight Nginx Alpine image.
  • Created a custom Dockerfile instead of manually configuring a container.
  • Used .dockerignore to 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.

Task Outcome

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.

About

A Dockerized Nginx web server demonstrating containerization, deployment, lifecycle management, monitoring, and troubleshooting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages