Run CosmosDB emulator locally using docker

In this blog , we will see how can we run cosmosdb emulator using docker on local machine.

Step-1 Retrieve the IP address of your local machine.

ipaddr="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"

Step-2 Pull the Docker image from the registry.

docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator

Step-3 – Run the Docker image with the below configuration.

docker run -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254  -m 3g --cpus=2.0 --name=test-linux-emulator -e AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10 -e AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true -e AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=$ipaddr -it mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator

Step-4 – After the emulator installed and running using docker .Now We need to install certificate .Use a different terminal, load the IP address of your local machine into a variable.

ipaddr="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"

Step-6 Download the certificate for the emulator.

curl -k https://$ipaddr:8081/_explorer/emulator.pem > emulatorcert.crt

Step-7 Import certificate .If you are using mac .Open keychain access .Select File and Import Items and import the emulatorcert.crt.

Step-8 Double click on trust icon and change to always trust.

Step-9 – Run the below url

https://localhost:8081/_explorer/index.html

thanks !!

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *