This is a beginner DevOps project where I used Docker Compose to run a simple Node.js application and a MySQL database together.
The goal of this project is to understand how multiple containers work together in a local development environment.
- Running multiple containers with Docker Compose
- Connecting an application container to a database container
- Using environment variables for configuration
- Using Docker volumes for database persistence
- Adding a health check for MySQL
- Checking container logs for troubleshooting
- Docker
- Docker Compose
- Node.js
- Express.js
- MySQL
- mysql2
- VS Code
- Git/GitHub
devops-compose-basic-app/
│
├── app/
│ ├── Dockerfile
│ ├── package.json
│ └── server.js
│
├── db/
│ └── init.sql
│
├── docker-compose.yml
├── .env.example
├── .gitignore
└── README.md
git clone <your-repository-url>
cd devops-compose-basic-appCreate a .env file in the root folder:
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_DATABASE=bookdb
DB_HOST=mysql
DB_USER=root
DB_PASSWORD=rootpassword
DB_NAME=bookdb
DB_PORT=3306
APP_PORT=3000docker compose up --buildOr run in the background:
docker compose up -d --builddocker compose pscurl http://localhost:3000Health check:
curl http://localhost:3000/healthBooks API:
curl http://localhost:3000/booksdocker compose logs app
docker compose logs mysqldocker compose downTo remove the database volume and reset data:
docker compose down -v