MongoDB Deployment Example
This guide demonstrates how to deploy a MongoDB instance using Instantly.run.
Deployment Command
docker run --context=instantly --name mongo-db --domainname db.example.com \
-e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=strongpassword \
-p 27017:27017 -v ssd:/data/db
Command Breakdown
--context=instantly
: Ensures the container is managed under the Instantly.run context.--name mongo-db
: Assigns the container a unique name for reference.--domainname db.example.com
: Assigns the container a public domain (used for internal access).- Environment Variables:
MONGO_INITDB_ROOT_USERNAME
: The root username for MongoDB.MONGO_INITDB_ROOT_PASSWORD
: The root password for MongoDB.
-p 27017:27017
: Maps the MongoDB service port to the host.-v ssd:/data/db
: Mounts a volume to persist MongoDB data.
Accessing the Deployment
- Internal Hostname: The MongoDB instance will be accessible internally at
db-example-com:27017
. - Public Access: MongoDB is not exposed publicly due to Instantly.run's HTTP/HTTPS limitation for public domains.
Modifying the Deployment
To make updates (e.g., change the credentials or volumes), re-run the command with updated parameters. For example, to change the volume mapping:
docker run --context=instantly --name mongo-db --domainname db.example.com \
-e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=newpassword \
-p 27017:27017 -v hdd:/data/db
Additional Configuration
For more configuration options, refer to the MongoDB Docker Documentation.