Dockerのmongodbインスタンスにjson配列のアイテムをインポートしようとしています。ドッカーせずにしようとすると、mongoimportはimported 7 documents
で応答しますが、ドッカーではimported 1 document
mongoimportを使用してドッキングされたmongodbがアイテムとしてjsonの配列をインポートする
ドッカーコマンドに応答します。
CMD mongoimport --host mongodb --db reach-engine --collection domains --type json --file seed.json --jsonArray
ドッカーのMongoDB:
{ "_id" : ObjectId("58dc3abd7ccf9a826b2a7d34"), "items" : [ { "id" : 1, "_id" : "item1", "type" : "alert", "title" : "hello.world", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$9.00", "active" : true }, { "id" : 2, "_id" : "item2", "type" : "welcome.lol", "title" : "Item 2", "email" : "[email protected]", "message" : "lol", "createdDate" : "date", "price" : "$12.00", "active" : true }, { "id" : 3, "_id" : "item3", "type" : "message", "title" : "various.domain", "email" : "[email protected]", "message" : "lol", "createdDate" : "date", "price" : "$3.00", "active" : false }, { "id" : 4, "_id" : "item4", "type" : "message", "title" : "something.else", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }, { "id" : 5, "_id" : "item5", "type" : "update", "title" : "wow.lol", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }, { "id" : 6, "_id" : "item6", "type" : "update", "title" : "domainname.net", "email" : "[email protected]", "message" : "cars", "createdDate" : "date", "price" : "$12.00", "active" : false }, { "id" : 7, "_id" : "item7", "type" : "update", "title" : "something.lol", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false } ] }
現地のMongoDB:
{ "_id" : ObjectId("58dc21cf1ebe0a21fa2fcdd4"), "title" : "hello.world", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$9.00", "active" : true }
{ "_id" : ObjectId("58dc21cf1ebe0a21fa2fcdd5"), "title" : "Item 2", "email" : "[email protected]", "message" : "lol", "createdDate" : "date", "price" : "$12.00", "active" : true }
{ "_id" : ObjectId("58dc21cf1ebe0a21fa2fcdd6"), "title" : "wow.lol", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc21cf1ebe0a21fa2fcdd7"), "title" : "domainname.net", "email" : "[email protected]", "message" : "cars", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc21cf1ebe0a21fa2fcdd8"), "title" : "something.lol", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc21cf1ebe0a21fa2fcdd9"), "title" : "something.else", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc21cf1ebe0a21fa2fcdda"), "title" : "various.domain", "email" : "[email protected]", "message" : "lol", "createdDate" : "date", "price" : "$3.00", "active" : false }
{ "_id" : ObjectId("58dc2b7c1ebe0a21fa2fcddb"), "title" : "hello.world", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$9.00", "active" : true }
{ "_id" : ObjectId("58dc2b7c1ebe0a21fa2fcddc"), "title" : "Item 2", "email" : "[email protected]", "message" : "lol", "createdDate" : "date", "price" : "$12.00", "active" : true }
{ "_id" : ObjectId("58dc2b7c1ebe0a21fa2fcddd"), "title" : "various.domain", "email" : "[email protected]", "message" : "lol", "createdDate" : "date", "price" : "$3.00", "active" : false }
{ "_id" : ObjectId("58dc2b7c1ebe0a21fa2fcdde"), "title" : "something.else", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc2b7c1ebe0a21fa2fcddf"), "title" : "wow.lol", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc2b7c1ebe0a21fa2fcde0"), "title" : "domainname.net", "email" : "[email protected]", "message" : "cars", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc2b7c1ebe0a21fa2fcde1"), "title" : "something.lol", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc2d691ebe0a21fa2fcde2"), "title" : "various.domain", "email" : "[email protected]", "message" : "lol", "createdDate" : "date", "price" : "$3.00", "active" : false }
{ "_id" : ObjectId("58dc2d691ebe0a21fa2fcde3"), "title" : "Item 2", "email" : "[email protected]", "message" : "lol", "createdDate" : "date", "price" : "$12.00", "active" : true }
{ "_id" : ObjectId("58dc2d691ebe0a21fa2fcde4"), "title" : "hello.world", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$9.00", "active" : true }
{ "_id" : ObjectId("58dc2d691ebe0a21fa2fcde5"), "title" : "wow.lol", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc2d691ebe0a21fa2fcde6"), "title" : "domainname.net", "email" : "[email protected]", "message" : "cars", "createdDate" : "date", "price" : "$12.00", "active" : false }
{ "_id" : ObjectId("58dc2d691ebe0a21fa2fcde7"), "title" : "something.lol", "email" : "[email protected]", "message" : "", "createdDate" : "date", "price" : "$12.00", "active" : false }
ドッカーを命令:
mongodb_1 | 2017-03-29T21:38:09.439+0000 I COMMAND [conn1] command reach-engine.domains command: insert { insert: "domains", documents: [ { items: [ { id: 1, _id: "item1", type: "alert", title: "hello.world", email: "[email protected]", message: "", createdDate: "date", price: "$9.00", active: true }, { id: 2, _id: "item2", type: "welcome.lol", title: "Item 2", email: "[email protected]", message: "lol", createdDate: "date", price: "$12.00", active: true }, { id: 3, _id: "item3", type: "message", title: "various.domain", email: "[email protected]", message: "lol", createdDate: "date", price: "$3.00", active: false }, { id: 4, _id: "item4", type: "message", title: "something.else", message: "", createdDate: "date", price: "$12.00", active: false }, { id: 5, _id: "item5", type: "update", title: "wow.lol", email: "[email protected]", message: "", createdDate: "date", price: "$12.00", active: false }, { id: 6, _id: "item6", type: "update", title: "domainname.net", email: "[email protected]", message: "cars", createdDate: "date", price: "$12.00", active: false }, { id: 7, _id: "item7", type: "update", title: "something.lol", email: "[email protected]", message: "", createdDate: "date", price: "$12.00", active: false } ] } ], writeConcern: { getLastError: 1, w: 1 }, ordered: false } ninserted:1 keyUpdates:0 writeConflicts:0 numYields:0 reslen:40 locks:{ Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 1, W: 1 } }, Collection: { acquireCount: { W: 1 } } } protocol:op_query 250ms
この原因は何ですか?
は、あなたがこの問題を発見する時に使用しているDockerfile /ドッキングウィンドウ・コン構造に私を指してくださいもらえますか? –
ローカルにインストールしたMongoDBのバージョンと、ドッカーのコンテナにインストールしたバージョンを確認できますか?また、JSONファイルのスニペットを見ることは可能ですか? –