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.