Back to all templates
MongoDB logo

MongoDB

Database512MB+ RAM

Document-oriented NoSQL database for modern applications

databasenosqldocumentmongodb

Deploy MongoDB in 3 Steps

1

Connect Your VPS

Add your server credentials to Server Compass

2

Select MongoDB

Choose from our template library

3

Deploy & Configure

Fill in settings and click Deploy

No Docker knowledge required
Step-by-step deployment guide

Deploy MongoDB on a VPS with Server Compass

Use the MongoDB template in Server Compass to deploy a persistent MongoDB database on your VPS, then verify access from DB Admin.

About 5 minutesBrowser verified
1
Step 1

Open the server Apps tab

Select your VPS, open the Apps tab, and start a new app deployment. Keep sensitive server details hidden before capturing or sharing screenshots.

Server Compass Apps tab before creating a MongoDB app
2
Step 2

Choose an app template

Click New App and choose the template deployment path so Server Compass can load the built-in catalog.

Choosing to deploy an app from a Server Compass template
3
Step 3

Search for MongoDB

Use the template picker search to find MongoDB in the Server Compass template catalog.

Searching for MongoDB in the Server Compass template picker
4
Step 4

Select the MongoDB template

Choose the MongoDB template. Server Compass fills the Docker image, persistent volume, root user, generated password, port mapping, and database connection metadata.

MongoDB template selected in Server Compass
5
Step 5

Review the MongoDB settings

Confirm the app name and host port. In the pilot run, the app was named mongodb-demo and the host port was changed to 27018 to avoid conflicts with the default MongoDB port.

Reviewing MongoDB deployment settings and host port mapping
6
Step 6

Deploy MongoDB

Review the final settings, click Deploy Now, and let Server Compass create the MongoDB container and persistent volume on the VPS.

Reviewing MongoDB settings before clicking Deploy Now
7
Step 7

Watch the deployment progress

Keep the deployment modal open while Server Compass prepares the project, pulls the Docker image, starts the container, and checks the service status.

Server Compass deploying the MongoDB template on the VPS
8
Step 8

Confirm MongoDB is running

After deployment finishes, return to the Apps tab and confirm the MongoDB app is marked Running with its database connection section available.

MongoDB template running in the Server Compass Apps tab
9
Step 9

Open DB Admin to verify access

Open the MongoDB app details and switch to DB Admin. Seeing the DB Admin screen load the MongoDB connection confirms Server Compass can reach the deployed database without exposing generated credentials.

MongoDB DB Admin page showing the deployed database is reachable

After MongoDB Opens

  • Keep generated MongoDB credentials masked in screenshots and docs.
  • Create application databases, users, and collections from a trusted client or the Server Compass DB Admin workflow.
  • Restrict external access later if MongoDB only needs to be reachable from Docker apps on the same server.
  • Back up persistent volumes before using the database for production data.

Verified Result

Server Compass showed one running MongoDB container, host port 27018 mapped to 27017, and DB Admin loaded with the MongoDB connection available.

MongoDB deployment questions

What does the MongoDB template deploy?

It deploys the official MongoDB Docker image with persistent storage, generated root credentials, a port mapping, and Server Compass database metadata.

Which port did the pilot use?

The pilot used host port 27018 mapped to MongoDB port 27017 to avoid conflicts with any existing MongoDB service.

Why does DB Admin show no collections?

A fresh MongoDB deployment can be reachable even when no user-created collections exist yet. The important verification is that DB Admin loads through the deployed database connection.

Should this become a blog post?

No. The deployment guide should live on the MongoDB template detail page and be linked from the reusable template deployment docs page.

Self-Deploy Guide

DIY MongoDB Deployment

Learn how to self-host MongoDB with this hands-on deployment guide.

1

Access Your VPS via Terminal

Open a terminal session and log into your VPS. Replace the placeholder with your actual IP.

terminal
# Connect via SSH
ssh root@your-vps-ip

# Alternative with key file
ssh -i /path/to/key root@your-vps-ip

First time? Make sure Docker is installed on your VPS. Run: curl -fsSL https://get.docker.com | sh

2

Set Up Project Folder

Create a workspace for your deployment files.

terminal
# Create and navigate to project directory
mkdir -p ~/apps/mongodb
cd ~/apps/mongodb
3

Create the Compose File

Configure your containers with this Docker Compose setup:

docker-compose.yml
services:
  mongodb:
    image: mongo:7
    ports:
      - "27017:27017"
    environment:
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=<your-mongo-password>
      - MONGO_INITDB_DATABASE=app
    volumes:
      - mongodb_data:/data/db
      - mongodb_config:/data/configdb
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
      interval: 30s
      timeout: 10s
      retries: 5

volumes:
  mongodb_data:
  mongodb_config:
Setup Variables
PORTHost port to expose(default: 27017)
MONGO_USERRoot username(default: admin)
MONGO_PASSWORDRoot password
MONGO_DATABASEInitial database name(default: app)
4

Deploy Your Stack

Spin up the containers and verify the deployment.

terminal
# Start all services
docker compose up -d

# List running containers
docker compose ps

# Watch the logs
docker compose logs -f
5

Update Firewall Settings

Allow incoming traffic on the application port.

terminal
# Allow the application port through firewall
sudo ufw allow 27017/tcp
sudo ufw reload

# Access your app at:
# http://your-server-ip:27017
Skip the Terminal

Skip the terminal. Use Server Compass instead.

Let Server Compass handle the complexity. Deploy MongoDB with a simple, intuitive interface.

  • Beautiful interface
  • One-click deploys
  • Let's Encrypt SSL
  • Zero downtime
  • Container monitoring
  • Easy rollbacks
Download Server Compass$29 one-time • Lifetime license

After Deployment

After deploying MongoDB with Server Compass, complete these steps to finish setup

1

Test database connection using mongosh

2

Create additional databases and users for your applications

3

Set up monitoring and alerts

4

Configure backup schedules for the data volume

5

Consider upgrading to replica set for production (see MongoDB Replica Set template)

Need help? Check out our documentation for detailed guides.

MongoDB FAQ

Common questions about self-hosting MongoDB

How do I deploy MongoDB with Server Compass?

Simply download Server Compass, connect to your VPS, and select MongoDB from the templates list. Fill in the required configuration and click Deploy. The entire process takes under 3 minutes.

What are the system requirements for MongoDB?

MongoDB requires a minimum of 512MB RAM. We recommend a VPS with at least 1024MB RAM for optimal performance. Any modern Linux server with Docker support will work.

Can I migrate my existing MongoDB data?

Yes! Server Compass provides volume mapping that allows you to import existing data. You can also use standard MongoDB backup and restore procedures.

How do I update MongoDB to the latest version?

Server Compass makes updates easy. Simply click the Update button in your deployment dashboard, and the latest MongoDB image will be pulled and deployed with zero downtime.

Is MongoDB free to self-host?

MongoDB is open-source software. You only pay for your VPS hosting (typically $5-20/month) and optionally Server Compass ($29 one-time). No subscription fees or per-seat pricing.

Ready to Self-Host MongoDB?

Download Server Compass and deploy MongoDB to your VPS in under 3 minutes. No Docker expertise required.

Download Server Compass