Mongosh docker

Using docker exec to run commands on a mongodb container

Published on October 05, 2022 · 1 min read · 0 reading right now · 1 views

DOCKER
MONGODB

Connect

docker exec -it <container_name> mongosh -u <user_name> -p <password>

With -u an -p options being optional(obv).

Commands

show databases

use <database_name>

db.<collection_name>.find() # get all data in the collection
db.<collection_name>.insertOne({ ... }) # insert data in the collection

exit
0 likes

Comments

1 online · 0 visits
Nothing playing at the moment

Theme: