3
votes

I'm trying to get Cosmos DB Emulator running on Docker for Windows but I am not having any luck. I am following the commands here:

https://docs.microsoft.com/en-us/azure/documentdb/documentdb-nosql-local-emulator

Specifically:

md %LOCALAPPDATA%\DocumentDBEmulatorCert 2>nul
docker run -v %LOCALAPPDATA%\DocumentDBEmulatorCert:c:\DocumentDBEmulator\DocumentDBEmulatorCert -P -t -i mominag/documentdb_emulator

I am getting various errors from Docker including "invalid bind mount". The command itself doesn't seem right so I've tried changing mominag/documentdb_emulator to microsoft/azure-documentdb-emulator but that has not worked. It doesn't help that this is my first real attempt at using Docker.

I also took a look at the following on GitHub which looks like the source of the commands in the Microsoft docs.

https://github.com/Azure/azure-documentdb-emulator-docker

UPDATE: Here are the commands I am running and the errors that are returned.

PS C:\> md %LOCALAPPDATA%\DocumentDBEmulatorCert 2>nul
out-file : FileStream was asked to open a device that was not a file. For support for devices like 'com1:' or 'lpt1:',
call CreateFile, then use the FileStream constructors that take an OS handle as an IntPtr.
At line:1 char:1
+ md %LOCALAPPDATA%\DocumentDBEmulatorCert 2>nul
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (:) [Out-File], NotSupportedException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

PS C:\> docker run -v %LOCALAPPDATA%\DocumentDBEmulatorCert:c:\DocumentDBEmulator\DocumentDBEmulatorCert -P -t -i docume
ntdb_emulator
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: invalid bind mount spec "%LOCALAPPD
ATA%\\DocumentDBEmulatorCert:c:\\DocumentDBEmulator\\DocumentDBEmulatorCert": invalid volume specification: '%LOCALAPPDA
TA%\DocumentDBEmulatorCert:c:\DocumentDBEmulator\DocumentDBEmulatorCert'.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
PS C:\>

If I remove the 2>nul the directory is created but I still get the same error on the docker run command.

1
I just did it and it worked just fine. both the original command and microsoft/azure-documentdb-emulator worked fine, did you switch docker to windows mode\containers?4c74356b41
I had not switched to windows containers but I just did and I'm still getting an error. I will update the question with the specific error message.user1843640
i would suggest removing all virtual networks and installing docker from scratch4c74356b41

1 Answers

5
votes

According to your description, I have checked the command line via power shell, I found the directory is not created correctly as follows:

enter image description here

Note: you could replace %LOCALAPPDATA% with $env:LOCALAPPDATA.

When running the following command line to start the documentdb emulator:

docker run -v %LOCALAPPDATA%\DocumentDBEmulatorCert:c:\DocumentDBEmulator\DocumentDBEmulatorCert -P -t -i mominag/documentdb_emulator

I encountered the following error:

enter image description here

When I changing mominag/documentdb_emulator to microsoft/azure-documentdb-emulator, then I could start my documentdb emulator successfully as follows:

enter image description here