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
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