PS C:\Users\【user]> docker pull mongo:latest latest: Pulling from library/mongo 10ac4908093d: Pull complete 685504455d09: Pull complete ebd36404f329: Pull complete 3abd9b25affb: Pull complete 2d7fde532eae: Pull complete 24fc70e4c7d7: Pull complete ffc2353072f7: Pull complete 560de8e3a6c7: Pull complete 0748cd1d792c: Pull complete Digest: sha256:2374c2525c598566cc4e62145ba65aecfe1bd3bf090cccce1ca44f3e2b60f861 Status: Downloaded newer image for mongo:latest docker.io/library/mongo:latest
PS C:\Users\[user]> docker run -d --name mongo_local_Test -p 27020:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=paSsw0rd mongo 840a5b0dd13fa7df72d69d59ec9b43f81841d10230aec8755b043f6bd007c672
PS C:\Users\[user]> docker exec -ti mongo_local_Test bash root@840a5b0dd13f:/# mongo bash: mongo: command not found root@840a5b0dd13f:/# mongosh Current Mongosh Log ID: 63f8327d328712821d9fa1e4 Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.2 Using MongoDB: 6.0.4 Using Mongosh: 1.6.2
root@840a5b0dd13f:/# mongosh -u admin -p paSsw0rd Current Mongosh Log ID: 63f832e1ec1b406b397debe6 Connecting to: mongodb://<credentials>@127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.2 Using MongoDB: 6.0.4 Using Mongosh: 1.6.2 For mongosh info see: https://docs.mongodb.com/mongodb-shell/ ------ The server generated these startup warnings when booting 2023-02-24T03:37:33.203+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem 2023-02-24T03:37:34.037+00:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never' 2023-02-24T03:37:34.037+00:00: vm.max_map_count is too low ------ ------ Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() ------ test> show dbs admin 100.00 KiB config 12.00 KiB local 72.00 KiB test> use test already on db test test> show dbs admin 100.00 KiB config 60.00 KiB local 72.00 KiB
test> db.testC.insert({"_id":1}) DeprecationWarning: Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite. { acknowledged: true, insertedIds: { '0': 1 } } test> show collections testC test> db.testC test.testC test> db.testC.find() [ { _id: 1 } ] test>
mongoDB 在docker中运行成功, 如何 将本地应用的数据 存储到docker的 mongodb中?
标签:Pull,container,complete,MongoDB,db,test,Docker,mongo From: https://www.cnblogs.com/panpanwelcome/p/17151148.html