MongoDB Database
NoSQL document database
Document-oriented NoSQL database using MongoDB latest version.
Docker Configuration
Image: mongo:latest
Ports: 27017:27017
Volume: damp-mongodb:/data/dbDAMP identifies the service using Docker labels. Container name is auto-generated by Docker.
Port Configuration
Default ports: 27017 (host) → 27017 (container)
If port 27017 is occupied on the host machine, DAMP automatically uses the next available port. Check the DAMP interface to see the actual port assigned.
Environment Variables
| Variable | Value | Description |
|---|---|---|
MONGODB_INITDB_ROOT_USERNAME | root | Root username |
MONGODB_INITDB_ROOT_PASSWORD | rootpassword | Root password |
Connection Information
From Host Machine (Windows)
Connect from your Windows host to the MongoDB service.
mongosh "mongodb://root:rootpassword@localhost:27017"Connection Details:
- Host:
localhost - Port:
27017(or actual port shown in DAMP) - Username:
root - Password:
rootpassword
Connection String:
mongodb://root:rootpassword@localhost:27017/development?authSource=adminFrom Project Containers
Connect from your DevContainers or other Docker containers to the MongoDB service.
Use the container name or ID shown in the DAMP interface.
# Using container name from DAMP
mongosh "mongodb://root:rootpassword@[container-name]:27017"Laravel .env Configuration (with MongoDB package):
MONGODB_HOST=[container-name]
MONGODB_PORT=27017
MONGODB_DATABASE=development
MONGODB_USERNAME=root
MONGODB_PASSWORD=rootpasswordReplace [container-name] with the actual container name displayed in DAMP.
Common Operations
Create Database & Collection
use my_app;
db.users.insertOne({ name: "John", email: "john@example.com" });List Databases
show dbsExport Collection
# From host
mongoexport --host=localhost --username=root --password=rootpassword \
--db=development --collection=users --out=users.json
# From project container (use container name from DAMP)
mongoexport --host=[container-name] --username=root --password=rootpassword \
--db=development --collection=users --out=users.jsonData Persistence
All data is stored in the damp-mongodb Docker volume. Removing the service preserves your databases.