A simple Node.js + Express backend containerized using Docker.
This project was built as my first hands-on experience with Docker, where I explored how to containerize a backend service, manage environment variables, and run applications inside containers.
- Backend: Node.js, Express.js
- Containerization: Docker
- Environment: WSL (Ubuntu)
- Config: dotenv
- Simple REST API using Express
- Dockerized backend application
- Environment variable support using
.env - Runs in background using containers
- Easy container lifecycle management
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Returns status message |
| GET | /api |
Returns JSON response |
git clone https://github.com/shreya-mishra325/docker-api
cd docker-api
npm install
npm start
docker build -t docker-api .
docker run -d -p 5000:5000 --env-file .env --name docker-api-container docker-api
docker ps
docker logs docker-api-container
docker stop docker-api-container
docker start docker-api-container
http://localhost:5000
http://localhost:5000/api
- Docker Desktop was consuming a lot of memory and frequently got stuck on "Starting Docker Engine"
- Even after multiple restarts, it didn’t work properly
- Had to uninstall Docker Desktop completely
👉 Final approach:
Switched to Docker inside WSL (Ubuntu), which was much lighter and worked reliably
-
.envfile not found → commands were run from wrong directory -
.envnot visible → learned hidden files requirels -a -
Container name conflicts → removed existing containers before running new ones
-
Multiple unused containers → cleaned using:
docker rm -f $(docker ps -aq)
- Difference between Docker image and container
- How to containerize a backend service
- Using
.envinside Docker - Running containers in background
- Debugging Docker issues in real scenarios
- Using Docker efficiently via WSL instead of Docker Desktop