CodeAlpha DevOps Internship — Task 4: Web Server using Docker
A minimal Flask web server, fully containerized with Docker, demonstrating image build, container lifecycle management, health checks, and monitoring.
CodeAlpha_DockerWebServer/
├── app.py # Flask app: /, /health, /info routes
├── requirements.txt
├── Dockerfile
├── docker-compose.yml
├── .dockerignore
└── .github/workflows/docker.yml
docker --version to confirmdocker build -t codealpha-webserver .
docker run -d -p 5000:5000 --name webserver codealpha-webserver
Visit:
http://localhost:5000/ — homepagehttp://localhost:5000/health — JSON health checkhttp://localhost:5000/info — container hostname/env infodocker compose up -d --build
Stop and remove:
docker compose down
These are the commands to run (and screenshot) for your submission/video:
docker ps # list running containers
docker logs webserver # view application logs
docker stats webserver # live CPU/memory usage
docker exec -it webserver sh # shell inside the running container
docker inspect webserver # full container metadata
docker stop webserver # stop
docker start webserver # start again
docker restart webserver # restart
docker rm -f webserver # remove
docker images # list built images
docker rmi codealpha-webserver # remove the image
The Dockerfile and docker-compose.yml both define a HEALTHCHECK that pings
/health every 30 seconds. After running the container, check its status with:
docker inspect --format='' webserver
A healthy status confirms the app is up inside the container.
-p 5001:5000docker logs webserver for a Python
traceback (most likely a missing dependency or syntax error)docker exec -it webserver sh lets you poke around the filesystem live to debug.github/workflows/docker.yml builds the image on every push, runs it, and hits
/health as a smoke test — proving the image builds and the container boots
correctly outside your machine too.
HEALTHCHECK, docker stats, /health endpoint)docker logs / docker exec