Skip to main content

Create MongoDB Database

curl -X POST "https://your-dokploy-instance.com/api/mongo.create" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production MongoDB",
    "appName": "prod-mongo",
    "databaseUser": "appuser",
    "databasePassword": "SecurePass123!",
    "dockerImage": "mongo:15",
    "environmentId": "env_123456",
    "description": "Main production MongoDB database",
    "replicaSets": false
  }'
name
string
required
Display name for the MongoDB database
appName
string
required
Unique application name used for Docker container identification
databaseUser
string
required
Username for database access
databasePassword
string
required
Password for database user. Must match pattern: ^[a-zA-Z0-9@#%^&*()_+\-=[\]{}|;:,.<>?~]*$`
environmentId
string
required
ID of the environment where this database will be deployed
dockerImage
string
default:"mongo:15"
Docker image to use for MongoDB
description
string
Optional description of the database instance
replicaSets
boolean
default:false
Enable MongoDB replica sets for high availability
serverId
string
Optional server ID for deployment on specific server
mongoId
string
Unique identifier for the created MongoDB instance
appName
string
Application name of the database
name
string
Display name of the database

Get MongoDB Database

curl -X GET "https://your-dokploy-instance.com/api/mongo.one?mongoId=mongo_123456" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
mongoId
string
required
ID of the MongoDB database to retrieve
mongoId
string
Database identifier
name
string
Display name
appName
string
Application name
databaseUser
string
Database username
dockerImage
string
MongoDB Docker image
applicationStatus
string
Current status: idle, running, done, or error
externalPort
number
External port for database access (if configured)
replicaSets
boolean
Whether replica sets are enabled

Deploy MongoDB

curl -X POST "https://your-dokploy-instance.com/api/mongo.deploy" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456"
  }'
mongoId
string
required
ID of the MongoDB database to deploy

Start MongoDB

curl -X POST "https://your-dokploy-instance.com/api/mongo.start" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456"
  }'
mongoId
string
required
ID of the MongoDB database to start

Stop MongoDB

curl -X POST "https://your-dokploy-instance.com/api/mongo.stop" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456"
  }'
mongoId
string
required
ID of the MongoDB database to stop

Update MongoDB

curl -X POST "https://your-dokploy-instance.com/api/mongo.update" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456",
    "name": "Updated MongoDB Database",
    "description": "Updated description",
    "memoryLimit": "2g",
    "memoryReservation": "1g",
    "cpuLimit": "1",
    "cpuReservation": "0.5"
  }'
mongoId
string
required
ID of the MongoDB database to update
name
string
New display name
appName
string
New application name
description
string
New description
databaseUser
string
Database username
databasePassword
string
User password
memoryLimit
string
Maximum memory (e.g., “2g”, “512m”)
memoryReservation
string
Guaranteed memory allocation
cpuLimit
string
Maximum CPU cores
cpuReservation
string
Guaranteed CPU allocation
command
string
Custom command override
args
array
Command arguments

Save External Port

curl -X POST "https://your-dokploy-instance.com/api/mongo.saveExternalPort" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456",
    "externalPort": 27017
  }'
mongoId
string
required
ID of the MongoDB database
externalPort
number
Port number for external access. Set to null to remove external port.

Save Environment Variables

curl -X POST "https://your-dokploy-instance.com/api/mongo.saveEnvironment" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456",
    "env": "MONGO_INITDB_DATABASE=myapp\nMONGO_CUSTOM_CONFIG=value"
  }'
mongoId
string
required
ID of the MongoDB database
env
string
Environment variables in KEY=VALUE format, separated by newlines

Reload MongoDB

curl -X POST "https://your-dokploy-instance.com/api/mongo.reload" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456",
    "appName": "prod-mongo"
  }'
mongoId
string
required
ID of the MongoDB database
appName
string
required
Application name of the database

Rebuild MongoDB

curl -X POST "https://your-dokploy-instance.com/api/mongo.rebuild" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456"
  }'
mongoId
string
required
ID of the MongoDB database to rebuild

Remove MongoDB

curl -X POST "https://your-dokploy-instance.com/api/mongo.remove" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mongoId": "mongo_123456"
  }'
mongoId
string
required
ID of the MongoDB database to remove

Connection String Format

Standard Connection

mongodb://[databaseUser]:[databasePassword]@[appName]:27017
Example:
mongodb://appuser:SecurePass123!@prod-mongo:27017

With Database Name

mongodb://[databaseUser]:[databasePassword]@[appName]:27017/[databaseName]

External Connection

mongodb://appuser:[email protected]:27017

Replica Set Connection

mongodb://[databaseUser]:[databasePassword]@host1:27017,host2:27017,host3:27017/?replicaSet=myReplicaSet

Mount Path

MongoDB data is stored at /data/db inside the container.

Build docs developers (and LLMs) love