Run MongoDB Locally in MongoDB

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

Run MongoDB Locally

Start MongoDB Community in Docker and connect with mongosh.

bash
# Requires Docker
docker run --name mongodb \
  -p 27017:27017 \
  -d mongodb/mongodb-community-server:8.0-ubi8
๐Ÿ“Œ The container keeps data until you remove the container
๐Ÿ’ก Add a named volume when local data must survive replacement
๐Ÿ” 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