Run the CosmosDB Emulator on Apple Silicon machines
The cosmosdb emulator doesn’t support running in the arm64 architecutre. There is an issue about that, but there was no workaround of that problem. I found a workaround to run this emulator on my M1 MacBook Pro, so I’d like to note how to do it.
* I wrote this in the issue as a comment, but I would like to copy into my blog as well.
Hello, recently I found a workaround for using the CosmosDB Emulator on my M1 MacBook Pro.
I use colima with a VM which architecutre is x86_64
.
There were some issues with the combination of the latest versions, so we have to use the specific versions of colima and an emulator at this time.
- Install colima@0.6.8
⚠️ When I used the latest version(0.6.9), the emulator didn’t start. The cause seems to be the VM image, which is updated in the latest version.
❯ curl -o colima@0.6.8 -L https://github.com/abiosoft/colima/releases/download/v0.6.8/colima-Darwin-arm64
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 7759k 100 7759k 0 0 994k 0 0:00:07 0:00:07 --:--:-- 1114k
❯ colima@0.6.8 version
colima version 0.6.8
git commit: 9b0809d0ed9ad3ff1e57c405f27324e6298ca04f
- Create a VM with
--arch
option
To emulate x86_64 architecutre, we have to use this option.
⚠️ I tried with rosetta options, but the emulator didn’t run.
❯ colima@0.6.8 start -p x86_64 --arch x86_64
- Run an emulator tagged
mongodb
❯ docker run \
--publish 8081:8081 \
--publish 10250-10255:10250-10255 \
--interactive \
--tty \
--env AZURE_COSMOS_EMULATOR_PARTITION_COUNT=1 \
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:mongodb
Unable to find image 'mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:mongodb' locally
mongodb: Pulling from cosmosdb/linux/azure-cosmos-emulator
...
Digest: sha256:28188604ad7be14497e1eb19757a6dd161b38dbb0508581b87fcda17879ebc34
Status: Downloaded newer image for mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:mongodb
This is an evaluation version. There are [121] days left in the evaluation period.
Starting
Started 1/2 partitions
Started 2/2 partitions
Started
⚠️ The latest version doesn’t work in my environment. The images that I downloaded is the following.
❯ docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator latest sha256:bf9ddf53430701e6d954bdc8cd07ef672f0642a55244e2d4b0b478a633e89d27 b05a7af77243 3 weeks ago 2.35GB
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator mongodb sha256:28188604ad7be14497e1eb19757a6dd161b38dbb0508581b87fcda17879ebc34 94581d68a4f3 7 weeks ago 2.27GB
- Then, you can access
https://localhost:8081/_explorer/index.html
🎉
Actually, a month ago, it had worked when I used the latest version of colima and the emulator. And I tried in the new environment, then, I faced some issues and investigates how to work. I don’t know why the emulator is tagged “mongodb”, but it works in my environment.
I hope this helps you 🙏
The cover image was generated by DALL·E 3 and the prompt is the following.
Colimaを利用してx86_64をエミュレートして、CosmosDBEmulatorをAppleSilicon上で動かすためのブログのアイキャッチ画像
This was the first time to use Generative AI to generate the image, but I surprised that even though the prompt is very rough, the generated image was decent…