mongodbHow to create a database with MongoDB on Docker?
Creating a MongoDB database with Docker is a simple process.
- Pull the MongoDB image from Docker Hub:
docker pull mongo
- Run the MongoDB container:
docker run -d -p 27017:27017 --name mongodb mongo
- Connect to the MongoDB container:
docker exec -it mongodb bash
- Create a database:
mongo
use my_database
The above steps will create a MongoDB database called my_database
on Docker.
Helpful links
Related
More of Mongodb
- How to use watch in MongoDB?
- How to update many documents in MongoDB?
- How to drop a database in MongoDB?
- How to use unwind in MongoDB?
- How to rename a field in MongoDB?
- How to query with "not equal" condition in MongoDB?
- How to list MongoDB users?
- How to sort MongoDB query results?
- How to work with JSON data in MongoDB?
- How to use regex in MongoDB?
See more codes...