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 check the version of MongoDB?
- How to work with time series data in MongoDB?
- How to use MongoDB queue?
- How to use watch in MongoDB?
- How to join two collections in MongoDB?
- How to drop a database in MongoDB?
- How to specify a password for MongoDB Docker?
- How to update an array element in MongoDB?
- How to use unwind in MongoDB?
- How to use triggers in MongoDB?
See more codes...