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 use triggers in MongoDB?
- How to create a many to many relation in MongoDB?
- How to use the limit operator in MongoDB?
- How to work with time series data in MongoDB?
- How to empty an array in MongoDB?
- How to check the version of MongoDB?
- How to update an array element in MongoDB?
- How to update many documents in MongoDB?
- How to use transactions in MongoDB?
See more codes...