I’m trying to run MongoDB in docker on my windows 11 pro pc and I keep getting an error that isn’t very helpful. The command is long/extensive to me and this is my 1st time working with docker or mongo on my pc. Can anyone help me with getting this command to run? I’ve copied and pasted the command from a file as well as I’ve typed it in manually.
here is the command:
docker run -it -d --name mongo-container
-p 27017:27017 --network MyDockerNetwork
--restart always
-v mongodb_data_container:/data/db
mongo:latest
I typed the command in manually, as well as copied and pasted it in. I expected to have MongoDB installed in docker after executing the command.
2
Answers
First, if the network "MyDockerNetwork" doesn’t exist, you need to create it with this command:
As well as the volume:
And then run the command:
You’re using a backslash
as a line-continuation character with Widows Command Prompt
cmd
. That only works for Unix/Linux/Mac shells or Git Bash, etc. on Windows.Use the caret
^
character instead. Shift + 6 on most keyboards. More details in this answer.Output shows ‘More?’ on each continued line until the last: