📢 Found an issue or want to request a new tool? Open an issue on GitHub
Modern MongoDB shell for interacting with MongoDB databases.
# Interactive mode
docker run -it --rm \
ghcr.io/pabpereza/toolkitbox/mongo:latest \
mongosh "mongodb://my-server:27017"
# With authentication
docker run -it --rm \
ghcr.io/pabpereza/toolkitbox/mongo:latest \
mongosh "mongodb://user:password@my-server:27017/database"
# Run single command
docker run --rm \
ghcr.io/pabpereza/toolkitbox/mongo:latest \
mongosh "mongodb://my-server:27017" --eval "db.getCollectionNames()"
apiVersion: v1
kind: Pod
metadata:
name: mongo-client
spec:
containers:
- name: mongo-client
image: ghcr.io/pabpereza/toolkitbox/mongo:latest
command: ["sleep", "infinity"]
env:
- name: MONGODB_URI
valueFrom:
secretKeyRef:
name: mongo-credentials
key: uri
mongosh is the official MongoDB shell that replaces the legacy mongo shell. It provides a rich command line interface with autocomplete, syntax highlighting, and full JavaScript support.
This component downloads and installs mongosh directly from the official MongoDB binaries. Supports x64 and arm64 architectures.
mongosh
mongosh "mongodb://hostname:27017"
mongosh "mongodb://user:password@hostname:27017/database"
mongosh "mongodb+srv://cluster.mongodb.net/mydb" --username user
mongosh --eval "db.getCollectionNames()"
mongosh script.js
// Show databases
show dbs
// Use database
use my_database
// Show collections
show collections
// Find documents
db.my_collection.find()
// Insert document
db.my_collection.insertOne({ name: "example" })
// Find with filter
db.my_collection.find({ field: "value" })
// Count documents
db.my_collection.countDocuments()
// Create index
db.my_collection.createIndex({ field: 1 })
| Option | Description |
|---|---|
--host | MongoDB server |
--port | Port (default: 27017) |
--username | Authentication user |
--password | Password |
--authenticationDatabase | Authentication database |
--eval | Execute JavaScript expression |
v3.6 - MongoDB 3.6 (uses classic mongo shell)v4.4 - MongoDB 4.4 (uses classic mongo shell)Content type
Image
Digest
sha256:0a204209d…
Size
53.1 MB
Last updated
17 days ago
docker pull toolkitbox/mongo