我尝试按照以下说明在 Docker 容器中运行 Azure CosmosDB 模拟器:
https://learn.microsoft.com/en-us/azure/cosmos-db/local-emulator#running-on-docker
描述的主要命令是:
md %LOCALAPPDATA%\CosmosDBEmulatorCert 2>null
docker run -v %LOCALAPPDATA%\CosmosDBEmulatorCert:C:\CosmosDB.Emulator\CosmosDBEmulatorCert -P -t -i -m 2GB microsoft/azure-cosmosdb-emulator
下一条指令是在主机上导入 SSL 证书:
cd/d %LOCALAPPDATA%\CosmosDBEmulatorCert
powershell .\importcert.ps1
但是该文件夹是空的 - 没有证书,也没有 powershell 脚本。
同样,容器上的 C:\CosmosDB.Emulator\CosmosDBEmulatorCert
文件夹也是空的。
当一切都初始化时,有一行内容:
-a---- 10/18/2018 4:50 PM 513 CosmosDbEmulatorCert.cer
但我在任何地方都看不到证书
最佳答案
请改用以下说明: https://hub.docker.com/r/microsoft/azure-cosmosdb-emulator/
run 命令显示略有不同。它使用 --mount
而不是-v
处理卷和绑定(bind)的选项:
(将 %hostDirectory%
替换为您要存储证书(如 C:\Users\<youruser>\AppData\Local\azure-cosmosdb-emulator-hostd
)的路径,或在脚本中声明它)
docker run --name azure-cosmosdb-emulator --memory 2GB --mount "type=bind,source=%hostDirectory%,destination=C:\CosmosDB.Emulator\bind-mount" -P --interactive --tty microsoft/azure-cosmosdb-emulator
然后您可以关闭交互式 shell。它将继续运行。
关于Docker 上的 Azure CosmosDB 模拟器不生成证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52878415/