连接Docker容器中的Cosmos Emulator DB



我开发了一个。NET核心应用程序使用本地Cosmos DB使用Cosmos DB模拟器。

应用程序正在运行&在本地Cosmos DB中添加新数据;IIS Express";,但是当我将运行模式改变为"0"时;Docker";,系统无法连接";https://localhost:8081/"本地Cosmos DB。

我试过docker作曲:

version: '3.4'
services:
app:
build:
context: .
dockerfile: Dockerfile
depends_on:
- cosmosdb
cosmosdb: 
image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator

您还需要添加端口,请尝试

cosmosdb:
image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
mem_limit: 3g
cpu_count: 2
environment:
AZURE_COSMOS_EMULATOR_PARTITION_COUNT: 10
AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE: "true"
AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE: ${IPADDR}
ports:
- "8081:8081"
- "10251:10251"
- "10252:10252"
- "10253:10253"
- "10254:10254"

https://localhost:8081不在docker容器中。试着找出主机名并使用它https://cosmosdb:8081

最新更新