CosmosDb Emulator with docker-compose

Viewed 891

I can successfully bring up a CosmosDb Emulator instance within docker-compose, but the data I am trying to seed has more than 25 static containers, which is more than the default emulator allows. Per https://docs.microsoft.com/en-us/azure/cosmos-db/emulator-command-line-parameters#set-partitioncount you can set this partition count higher with a parameter, but I am unable to find a proper entrypoint into the compose that accepts that parameter.

I have found nothing in my searches that affords any insight into this as most people have either not used compose or not even used Docker for their Cosmos Emulator instance. Any insight would be appreciated.

Here is my docker-compose.yml for CosmosDb:

services:
  cosmosdb:
    container_name: "azurecosmosemulator"
    hostname: "azurecosmosemulator"
    image: 'mcr.microsoft.com/cosmosdb/windows/azure-cosmos-emulator'
    platform: windows
    tty: true
    mem_limit: 2GB
    ports:
      - '8081:8081'
      - '8900:8900'
      - '8901:8901'
      - '8902:8902'
      - '10250:10250'
      - '10251:10251'
      - '10252:10252'
      - '10253:10253'
      - '10254:10254'
      - '10255:10255'
      - '10256:10256'
      - '10350:10350'
    networks:
      default:
        ipv4_address: 172.16.238.246
    volumes:
      - '${hostDirectory}:C:\CosmosDB.Emulator\bind-mount'

I have attempted to add a command in there for starting the container, but it does not accept any arguments I have tried.

1 Answers

My answer for this was a work around. Ultimately, running windows and linux containers side-by-side was a sizeable pain. Recently, Microsoft put out a linux container version of the emulator, which allowed me to provide an environment variable for partition counts, and run the process far more efficiently.

Reference here: https://docs.microsoft.com/en-us/azure/cosmos-db/linux-emulator?tabs=ssl-netstd21

Related