How to Setup MongoDB with Docker Compose + Use Mongo Shell ( Mongo DB + Docker + Mongo CLI / Shell )

preview_player
Показать описание
How to setup MongoDB with Docker Compose. Quick and easy tutorial for setting this database up with docker. Also shows how to use the Mongo Shell or CLI to modify data.

Reminder to ensure docker is running in the background.

Commands to start:
docker-compose up -d

Commands to stop:
docker-compose down

Commands to run CLI via container:
docker exec -it mongodb bash

mongo --username root --password password --authenticationDatabase admin

Timeline:
0:00 - Create Project and Compose file

🎵 Track Info
––––––––––––––––––––––––––––––
Creative Commons — Attribution 3.0 Unported — CC BY 3.0
––––––––––––––––––––––––––––––
Рекомендации по теме
Комментарии
Автор

Your video was of great help, thank you!

yzhjzgx
Автор

if you get error like 'bash: mongo: command not found' you should use mongosh instead mongo

ahmet-mujde
Автор

If your guys container is constantly reloading and raising "raise CalledProcessError(retcode, process.args, Command '['mongod', '--auth', '--bind_ip_all']' returned non-zero exit status 14." error, just make this adjust to the volume:

mongodb:
image:
container_name: mongodb
restart: unless-stopped
environment:
MONGODB_INITDB_ROOT_USERNAME: admin
MONGODB_INITDB_ROOT_PASSWORD: admin
ports:
- 27017:27017
volumes:
- data_db:/data/db

volumes:
data_db:

it worked for me

owwxmds