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]com", "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/docker-compose 구조를 알려주십시오. –
로컬에 설치 한 MongoDB의 버전과 도커 컨테이너에 설치 한 버전을 확인할 수 있습니까? 또한 JSON 파일의 스 니펫을 볼 수 있습니까? –