我在Visual Studio中有一个docker-compose项目,它启动了3个服务。其中一个使用cosmosdb。
我已经按照https://hub.docker.com/r/microsoft/azure-cosmosdb-emulator/上的说明在docker容器中启动了模拟器,并且它起作用了。
但现在我想通过docker-compose文件启动并运行它。以下是我的当前配置。
version: '3.4'
services:
gateway:
environment:
- ASPNETCORE_ENVIRONMENT=Development
image: ${DOCKER_REGISTRY-}gateway
ports:
- "7000:80"
depends_on:
- servicea
- serviceb
build:
context: .\ApiGateways\IAGTO.Fenix.ApiGateway
dockerfile: Dockerfile
servicea:
environment:
- ASPNETCORE_ENVIRONMENT=Development
image: ${DOCKER_REGISTRY-}servicea
depends_on:
- email.db
build:
context: .\Services\ServiceA
dockerfile: Dockerfile
serviceb:
environment:
- ASPNETCORE_ENVIRONMENT=Development
image: ${DOCKER_REGISTRY-}serviceb
build:
context: .\Services\ServiceB
dockerfile: Dockerfile
email.db:
image: microsoft/azure-cosmosdb-emulator
container_name: cosmosdb-emulator
ports:
- "8081:8081"当我运行docker container list时,可以看到容器正在运行

但是对https://localhost:8081/_explorer/index.html的请求失败了。
在这方面的任何帮助都非常感谢
发布于 2020-07-07 10:57:42
我也处于同样的情况,但是容器是用下面的docker-compose.yml启动的,它变得可以访问了。
我可以浏览https://localhost:8081/_explorer/index.html
version: '3.7'
services:
cosmosdb:
container_name: cosmosdb
image: microsoft/azure-cosmosdb-emulator
tty: true
restart: always
ports:
- "8081:8081"
- "8900:8900"
- "8901:8901"
- "8979:8979"
- "10250:10250"
- "10251:10251"
- "10252:10252"
- "10253:10253"
- "10254:10254"
- "10255:10255"
- "10256:10256"
- "10350:10350"
volumes:
- vol_cosmos:C:\CosmosDB.Emulator\bind-mount
volumes:
vol_cosmos: 可能我需要设置"tty“或"volumes”。
发布于 2019-05-10 04:13:54
部分问题是模拟器需要一段时间才能启动,并且在停止等待之前有2分钟的超时。我正在试着破解它,但我并没有取得太多成功。目前,镜像只能独立工作(通过docker run),仅此而已。
发布于 2021-06-23 01:39:03
使用linux cosmos db镜像,我将其设置如下:
version: '3.4'
services:
db:
container_name: cosmosdb
image: "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator"
tty: true
restart: always
mem_limit: 2G
cpu_count: 2
environment:
- AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10
- AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true
ports:
- "8081:8081"
- "8900:8900"
- "8901:8901"
- "8979:8979"
- "10250:10250"
- "10251:10251"
- "10252:10252"
- "10253:10253"
- "10254:10254"
- "10255:10255"
- "10256:10256"
- "10350:10350"
volumes:
- vol_cosmos:/data/db
volumes:
vol_cosmos:
https://stackoverflow.com/questions/55573965
复制相似问题