This project demonstrates the containerization and deployment of a web application using Docker technologies. The application consists of a Node.js backend connected to a PostgreSQL database. Docker Compose is used to orchestrate the containers, while Docker networking concepts such as Macvlan and bridge networking are demonstrated.
The objective of the project is to understand containerized deployment, service orchestration, persistent storage, and networking using Docker.
The main objectives of this project are:
The system architecture consists of two containers:
The backend communicates with the PostgreSQL container through a Docker network.
The backend is implemented using Node.js and Express.
The backend server connects to the PostgreSQL database using the pg library and provides an API endpoint.
This endpoint queries the database and returns the current time from PostgreSQL.
The backend Dockerfile builds the Node.js application container.
Key steps include:
The PostgreSQL container is built using the official PostgreSQL image and configured using environment variables.
Docker Compose is used to run multiple containers together.
The configuration defines:
The following screenshot shows the container build process and service initialization.

The containers are started using Docker Compose.
The backend container starts the Node.js server and connects to PostgreSQL.

The following screenshot shows the running containers using the docker ps command.

Docker networks allow containers to communicate with each other.
The network inspection command used:
Screenshot:

Each container receives an IP address within the Docker network.
Screenshot showing container details:

Docker volumes are used to persist database data even when containers are stopped or restarted.
Screenshot showing volume persistence:

Macvlan networking allows containers to appear as physical devices on the network.
Screenshot:

The backend successfully connects to PostgreSQL and returns the database timestamp.
Example output:
Screenshot:

| Image | Approx Size |
|---|---|
| Node.js Base Image | ~350 MB |
| PostgreSQL Image | ~300 MB |
Using optimized Docker builds helps reduce image size and improve deployment performance.
| Feature | Macvlan | Ipvlan |
|---|---|---|
| IP per Container | Yes | Yes |
| Performance | High | Very High |
| Isolation | Strong | Moderate |
| Complexity | Moderate | Higher |