Last update at :2024-05-18,Edit by888u
MongoDB is a free, open source, cross-platform, document-oriented NoSQL database program.
1. View available MongoDB versions
Visit the MongoDB mirror library address: https://hub.docker.com/_/mongo?tab=tags&page=1.
You can view other versions of MongoDB through Sort by. The default is the latest version mongo:latest.
You can also find other versions you want in the drop-down list:
In addition, we can also use the docker search mongo command to view the available versions:
$ docker search mongo NAME DESCRIPTION STARS OFFICIAL AUTOMATED mongo MongoDB document databases ... 1989 [OK] mongo-express Web-based MongoDB admin int... 22 [OK] mvertes/alpine-mongo light MongoDB container 19 [OK] mongooseim/mongooseim-docker MongooseIM server the lates... 9 [OK] torusware/speedus-mongo Always updated official Mon... 9 [OK] jacksoncage/mongo Instant MongoDB sharded cluster 6 [OK] mongoclient/mongoclient Official docker image for M... 4 [OK] jadsonlourenco/mongo-rocks Percona Mongodb with Rocksd... 4 [OK] asteris/apache-php-mongo Apache2.4 + PHP + Mongo + m... 2 [OK] 19hz/mongo-container Mongodb replicaset for coreos 1 [OK] nitra/mongo Mongo3 centos7 1 [OK] ackee/mongo MongoDB with fixed Bluemix p... 1 [OK] kobotoolbox/mongo https://github.com/kobotoolb... 1 [OK] valtlfelipe/mongo Docker Image based on the la... 1 [OK]
2. Get the latest version of MongoDB image
Here we pull the official latest version of the image:
$ docker pull mongo:latest
3. View local mirror
Use the following command to see if mongo is installed:
$ docker images
As you can see in the picture above, we have installed the latest version of the mongo image.
4. Run the container
After the installation is complete, we can use the following command to run the mongo container:
$ docker run -itd --name mongo -p 27017:27017 mongo --auth
Parameter description:
- -p 27017:27017: Map the 27017 port of the container service to the 27017 port of the host. Mongo services can be accessed from the outside directly through the host IP:27017.
- –auth: Requires a password to access the container service.
5. Installation successful
Finally, we can view the running information of the container through the docker ps command:
Then use the following commands to add a user and set a password, and try to connect.
$ docker exec -it mongo mongo admin #Create a user named admin with password 123456. > db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]}); # Attempt to connect using the user information created above. > db.auth('admin', '123456')
Recommended site searches: US website space, website registration system, local IP query, US free virtual host, Hong Kong virtual host space, Korean virtual host, host server rental, free domain name space, Japanese proxy server IP US server, < /p>
发表评论