docker-compose.yml file by default, the Makefile includes commands for managing Docker Compose services, primarily for running MongoDB locally.
Docker Requirements
You’ll need Docker and Docker Compose installed:- Docker Desktop (includes Docker Compose)
- Or Docker Engine + Docker Compose plugin
Creating docker-compose.yml
Create abackend/docker-compose.yml file to run MongoDB locally:
Makefile Docker Commands
Thebackend/Makefile provides convenient commands for managing Docker services:
Start Services
docker-compose.yml. This command:
- Tries
docker compose up(Docker Compose V2) - Falls back to
docker-compose up(Docker Compose V1) if V2 is not available - Runs in attached mode (shows logs in terminal)
Stop Services
docker-compose.yml. This command:
- Tries
docker compose down(Docker Compose V2) - Falls back to
docker-compose down(Docker Compose V1) - Preserves volumes (data persists)
Environment Configuration
Update yourbackend/.env to connect to the Docker MongoDB instance:
Docker Compose V1 vs V2
The Makefile commands automatically handle both versions:- V2 (newer):
docker compose- Plugin-based, included in Docker Desktop - V1 (older):
docker-compose- Standalone binary
Useful Docker Commands
View running containers:MongoDB Data Persistence
Data is persisted in a named Docker volume (mongodb_data). This means:
- Data survives container restarts
- Data survives
docker-downanddocker-runcycles - Data is only deleted with
docker compose down -vor manual volume deletion
Production Considerations
Troubleshooting
Port Already in Use
If port 27017 or 6379 is already in use:.env:
Permission Denied
On Linux, you may need to add your user to the docker group:Container Won’t Start
Check logs for errors:- Port conflict (see above)
- Insufficient disk space
- Corrupted volume (remove and recreate)