Unable to start Azure Cosmos DB for Mongo API using the emulator on Docker for Linux (Preview)

Michael Pinheiro 21 Reputation points
2022-12-27T10:08:01.16+00:00

Hi,

I've been struggling to start Azure Cosmos DB for Mongo API. I am using docker for desktop with WSL2 based engine to deploy the emulator using the following docker-compose.yml.

version: '3.9'  
services:  
  local-cosmosdb:  
    container_name: local.cosmosdb  
    image: 'mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:mongodb'  
    tty: true  
    restart: always  
    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=${HOST_IP}  
      - AZURE_COSMOS_EMULATOR_ENABLE_MONGODB_ENDPOINT=4.2  
    ports:  
      - '8081:8081'  
      - '10251:10251'  
      - '10252:10252'  
      - '10253:10253'  
      - '10254:10254'  
      - '10255:10255'  
    volumes:  
      - vol_cosmos:/data/db  
  
volumes:  
  vol_cosmos:  

To start the stack I execute the following script.

#!/bin/bash  
  
export HOST_IP="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"  
  
echo "HOST_IP=${HOST_IP}"  
  
docker-compose up  

However cosmos db emulator fails to start with the following error on container logs.

./startEmulator.sh   
    HOST_IP=172.24.19.20  
    [+] Running 2/2  
     ⠿ Network deploy_default    Created                                                                                                                                                                                                            0.0s  
     ⠿ Container local.cosmosdb  Created                                                                                                                                                                                                            0.1s  
    Attaching to local.cosmosdb  
    local.cosmosdb  | This is an evaluation version.  There are [137] days left in the evaluation period.  
    local.cosmosdb exited with code 255  
    local.cosmosdb  | This is an evaluation version.  There are [137] days left in the evaluation period.  
    local.cosmosdb exited with code 255  
    local.cosmosdb  | This is an evaluation version.  There are [137] days left in the evaluation period.  
    local.cosmosdb exited with code 255  
    local.cosmosdb  | This is an evaluation version.  There are [137] days left in the evaluation period.  
    local.cosmosdb exited with code 255  
    local.cosmosdb  | This is an evaluation version.  There are [137] days left in the evaluation period.  
    local.cosmosdb exited with code 255  
    local.cosmosdb  | This is an evaluation version.  There are [137] days left in the evaluation period.  
  
  

If I remove the AZURE_COSMOS_EMULATOR_ENABLE_MONGODB_ENDPOINT environment variable, the emulator starts correctly however without the Mongo API.

Another note, if I keep the AZURE_COSMOS_EMULATOR_ENABLE_MONGODB_ENDPOINT environment variable but use versions 3.2, 3.6 and 4.0, I got the following error.

This is an evaluation version.  There are [137] days left in the evaluation period.  
Invalid endpoint type enabled; only SQL endpoint type is supported.  

Anyone with the same issue?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,452 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jami 75 Reputation points
    2023-04-22T20:55:30.3066667+00:00

    It seems like the issue you are facing is related to the configuration of the Azure Cosmos DB emulator for the Mongo API. There are a few things you can try to resolve the issue:

    1. Check the Docker logs: You can check the container logs for more details about the error by running the following command in your terminal: docker logs local.cosmosdb This should give you more information about the specific error that caused the container to exit with code 255.
    2. Verify the Azure Cosmos DB emulator version: Make sure you are using the latest version of the Azure Cosmos DB emulator for the Mongo API. You can find the latest version on the Azure Cosmos DB Emulator release page on GitHub.
    3. Check the environment variables: Double-check that all the environment variables in your docker-compose.yml file are correct. You can try removing the AZURE_COSMOS_EMULATOR_ENABLE_MONGODB_ENDPOINT environment variable to see if the emulator starts correctly without it.
    4. Increase memory limit: You can try increasing the memory limit for the container by changing the value of the mem_limit environment variable in the docker-compose.yml file. For example, you can try setting it to 4g or higher.
    5. Disable persistence: Try disabling data persistence by setting the AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE environment variable to false. This can help isolate the issue and narrow down the potential causes.
    6. Use SQL endpoint: The error message "Invalid endpoint type enabled; only SQL endpoint type is supported" suggests that the emulator may not be configured correctly for the Mongo API. You can try using the SQL endpoint instead by setting the AZURE_COSMOS_EMULATOR_ENABLE_SQL_API environment variable to true.
    7. Check for conflicts with other services: Make sure that there are no other services running on the same ports as the Azure Cosmos DB emulator. You can try changing the port mappings in the docker-compose.yml file to use different ports, or stopping any other services that may be conflicting with the emulator. I hope these suggestions help you resolve the issue with starting the Azure Cosmos DB emulator for the Mongo API using Docker.
    0 comments No comments