This is a simple Node.js web application designed for learning Docker containerization concepts.
This application is a basic Express.js web server that:
- Serves a static HTML page at the root (
/
) - Provides an API status endpoint at
/api/status
- Includes a health check endpoint at
/health
- Runs on port 3000 by default (configurable via PORT environment variable)
- app.js: Main application server file
- package.json: Node.js dependencies and project configuration
- public/index.html: Static HTML page that confirms successful containerization
- public/style.css: Styling for the web page
If you wanted to run this application directly (not required for assignment):
npm install
npm start
DO NOT MODIFY THE APPLICATION CODE
Your task is to containerize this existing application using Docker. You need to:
- Create a
Dockerfile
that properly containerizes this Node.js application - Build a Docker image from your Dockerfile
- Run a container from your image
- Verify the application works by accessing it in your browser
- To build the docker image run the command:
- To run your docker container in port 3000 run the command:
Answer the following question in the space below: How does containerization with Docker differ from using virtual machines, and why might a development team choose Docker containers over VMs for deploying applications like the one you just containerized?
Your Dockerfile should ensure:
- The application has Node.js runtime available
- All application files are copied into the container
- Dependencies are installed (
npm install
) - Port 3000 is exposed
- The application starts with
npm start
- The container can be accessed from your host machine
When your Docker container is running correctly:
- Navigate to
http://localhost:3000
(or whatever port you mapped) - You should see a success page confirming containerization worked
- The
/api/status
endpoint should return JSON status information
- Make sure your port mapping is correct in the
docker run
command - Check that all files are copied into the container
- Verify Node.js dependencies are installed in the container
- Use
docker logs <container-name>
to see application output
docker-assignment/
├── Dockerfile # You create this
├── app.js # Provided
├── package.json # Provided
├── public/ # Provided
│ ├── index.html # Provided
│ └── style.css # Provided
└── README.md # This file
Good luck with your Docker containerization!