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 remove a field from MongoDB?
- How to sort MongoDB query results?
- How to query with "not equal" condition in MongoDB?
- How to list MongoDB users?
- What is MongoDB default port?
- How to work with time series data in MongoDB?
- How to use watch in MongoDB?
- How to implement pagination in MongoDB?
- How to check if array is empty in MongoDB?
- How to rename a MongoDB collection?
See more codes...