A small vanilla JavaScript task-tracker app, containerized with Docker and served using nginx.
containerized-web-app/
├── app/
│ ├── index.html
│ ├── style.css
│ └── app.js
├── Dockerfile
├── .dockerignore
└── README.md
Just open app/index.html in a browser, or serve it with any static file
server, e.g.:
cd app
python3 -m http.server 8000Then visit http://localhost:8000
Build the image:
docker build -t task-tracker .Run the container, mapping container port 80 to local port 8080:
docker run -p 8080:80 task-trackerVisit the app at: http://localhost:8080
Stop the container:
docker ps # find the container ID
docker stop <id>- The
Dockerfileuses the lightweightnginx:alpinebase image. - It clears nginx's default web root and copies in the app's static files
(
index.html,style.css,app.js). - nginx serves the files on port 80 inside the container, which is mapped
to a port on the host machine via
-p.
- Writing a basic Dockerfile to containerize an existing app
- Choosing an appropriate lightweight base image for static content
- Mapping container ports to host ports for local access
- Project organization and
.dockerignoreusage for clean image builds