Containerized Student Records REST API built with Node.js and PostgreSQL using Docker Compose, Macvlan networking, and persistent Docker volumes.
This project implements a containerized Student Records Web Application using:
Client (Browser / Postman)
|
v
+-------------------------------+
| Backend Container |
| Node.js + Express |
| IP: 172.21.0.100 |
+-------------------------------+
|
v
+-------------------------------+
| Database Container |
| PostgreSQL |
| IP: 172.21.0.101 |
+-------------------------------+
|
v
Docker Volume (student_pgdata)
| Endpoint | Method | Description |
|---|---|---|
| /health | GET | Health check |
| /students | POST | Insert record |
| /students | GET | Fetch records |
{
"name": "Siddharth",
"roll_number": "CS01",
"department": "CSE",
"year": 3
}
docker network create \
--driver macvlan \
--subnet=172.21.0.0/16 \
--gateway=172.21.0.1 \
-o parent=eth0 \
student_macvlan
docker exec -it studentapi sh
wget -qO- http://localhost:3000/health
Output:
{"status":"ok"}
wget -qO- \
--header="Content-Type: application/json" \
--post-data='{"name":"Siddharth","roll_number":"CS01","department":"CSE","year":3}' \
http://localhost:3000/students
wget -qO- http://localhost:3000/students
docker compose down
docker compose up -d
Data remains stored due to Docker volume.
Due to macvlan host isolation, API is tested inside the container using wget.