且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用Mongo连接到运行Docker的Azure Cosmos DB仿真程序

更新时间:2023-11-18 16:24:10

在一阵沮丧的挠头之后,我找到了解决办法!根据仿真器指令的Docker container page,您需要运行以下docker命令:

docker run --name azure-cosmosdb-emulator --memory 2GB --mount "type=bind,source=%LOCALAPPDATA%CosmosDBEmulatorind-mount,destination=C:CosmosDB.Emulatorind-mount" --interactive --tty -e AZURE_COSMOS_EMULATOR_MONGODB_ENDPOINT=true -p 8081:8081 -p 8900:8900 -p 8901:8901 -p 8902:8902 -p 10250:10250 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254 -p 10255:10255 -p 10256:10256 -p 10350:10350 mcr.microsoft.com/cosmosdb/windows/azure-cosmos-emulator

重要的更改是增加了:-e AZURE_COSMOS_EMULATOR_MONGODB_ENDPOINT=true


更新:

我发现这会启用3.2协议,对于您需要使用的3.6协议:-e AZURE_COSMOS_EMULATOR_MONGODB_COMPUTE_ENDPOINT=true

github discussion中有更多讨论,有人还指出Gremlin&Casandra选项为:

  • -e AZURE_COSMOS_EMULATOR_GREMLIN_ENDPOINT=true
  • -e AZURE_COSMOS_EMULATOR_CASSANDRA_ENDPOINT=true