This repository contains Experiment-3, demonstrating Docker fundamentals through NGINX deployment, custom image creation, image comparison, volume usage, and preparation of a sample Flask web application for containerization.
To understand and implement Docker containerization concepts by:
EXPERIMENT-3/
│
├── Part 1/ # Official NGINX image
├── Part 2/ # Custom NGINX (Ubuntu base)
├── Part 3/ # Custom NGINX (Alpine base)
├── Part 4/ # Image comparison
├── Part 5/ # Custom HTML using volumes
├── Experiment 3 Part 2/
│ └── flask-app/ # Sample Flask web application
│ ├── app.py
│ └── requirements.txt
└── Readme.md
docker pull nginx:latest
docker run -d -p 8080:80 --name exp3-nginx nginx
curl http://localhost:8080
Default NGINX welcome page is displayed.
FROM ubuntu:22.04
RUN apt-get update && \
apt-get install -y nginx && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
docker build -t nginx-ubuntu .
docker run -d -p 8081:80 --name nginx-ubuntu nginx-ubuntu
Custom Ubuntu-based NGINX image successfully created.
FROM alpine:latest
RUN apk add --no-cache nginx
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
docker build -t nginx-alpine .
docker run -d -p 8082:80 --name nginx-alpine nginx-alpine
docker images nginx-alpine
Alpine-based image created (~16MB), demonstrating lightweight containers.
docker images | findstr nginx
docker history nginx
docker history nginx-ubuntu
docker history nginx-alpine
mkdir html
echo "<h1>Hello from Docker NGINX</h1>" > html/index.html
docker run -d -p 8083:80 -v "%cd%\html:/usr/share/nginx/html" nginx
Custom HTML page served successfully via NGINX.
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, Docker!'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
flask
python app.py
Access:
http://localhost:5000
Application tested locally before containerization.