MongoDB Single Replica
Single MongoDB replica set for use with clients needing a replica set.
Mongo Single Replica
railwayapp-templates/mongo-replica-set
Just deployed
/data/db
Init Single Replica
railwayapp-templates/mongo-replica-set
Just deployed
This template deploys a single MongoDB instance for your data layer needs.
Network Communication
All database communication is done over the private network.
Configuration tuning
To tune the configuration of your MongoDB instance, refer to the MongoDB documentation or the documentation page in Docker Hub.
Authentication
The MongoDB instance is deployed with standard authentication enabled.
Connecting to MongoDB
To connect to MongoDB from another service in Railway, you should create a URI in the service's environment variables. As an example:
MONGO_HOST=${{mongo.RAILWAY_PRIVATE_DOMAIN}}:27017
MONGO_URI=mongodb://${{mongo.MONGO_INITDB_ROOT_USERNAME}}:${{mongo.MONGO_INITDB_ROOT_PASSWORD}}@${{MONGO_HOST}}
With these variables set, you can then reference the MONGO_URI
environment variable when configuring the client in your service code.
Template source
The source for this template can be found in the Railway Templates GitHub.
The MongoDB instance is built directly from the official MongoDB image in Docker Hub.
Resources
- MongoDB documentation
- Tutorial: Deploy MongoDB on RailwayThis template deploys a single MongoDB instance for your data layer needs.
Network Communication
All database communication is done over the private network.
Configuration tuning
To tune the configuration of your MongoDB instance, refer to the MongoDB documentation or the documentation page in Docker Hub.
Authentication
The MongoDB instance is deployed with standard authentication enabled.
Connecting to MongoDB
To connect to MongoDB from another service in Railway, you should create a URI in the service's environment variables. As an example:
MONGO_HOST=${{mongo.RAILWAY_PRIVATE_DOMAIN}}:27017
MONGO_URI=mongodb://${{mongo.MONGO_INITDB_ROOT_USERNAME}}:${{mongo.MONGO_INITDB_ROOT_PASSWORD}}@${{MONGO_HOST}}
With these variables set, you can then reference the MONGO_URI
environment variable when configuring the client in your service code.
Template source
The source for this template can be found in the Railway Templates GitHub.
The MongoDB instance is built directly from the official MongoDB image in Docker Hub.
Resources
Template Content
Mongo Single Replica
railwayapp-templates/mongo-replica-setInit Single Replica
railwayapp-templates/mongo-replica-set