Run MongoDB Locally in MongoDB

From the MongoDB cheat sheet ยท Setup ยท verified Nov 2026

Run MongoDB Locally

Start MongoDB Community in Docker and connect with mongosh.

bash
# Requires Docker
docker run --name mongodb \
  -p 27017:27017 \
  -v mongodb-data:/data/db \
  -d mongodb/mongodb-community-server:9.0-ubi9-slim
๐Ÿ“Œ Data lives in the mongodb-data volume and survives container removal
๐Ÿ’ก Use ubi9-slim tags: ubi8, Ubuntu and non-slim tags are deprecated
๐Ÿ” mongosh connects to localhost port 27017 by default
โš ๏ธ Configure authentication before exposing MongoDB beyond localhost
installdockermongodb-communitymongosh

Continue with MongoDB

Save the full cheat sheet or work through every related task.

Back to the full MongoDB cheat sheet