Jonalca
Jonalca

Reputation: 576

Installing mongoDB as a docker image on Windows

I am trying to install mongoDB as a docker image on a Windows 10 machine. So far so good this is the process I used (which worked on another machine with the same configuration)

docker pull mongo //download the mongo image
docker run -it -d -p 21017:21017 --name mongodb mongo //run it
docker ps //Its right there!
docker exec -it mongodb bash //get the shell command

This is the error I get thrown:

container e65c8b920af38b4f93214c81a89bcb2337c95ae27fe84efcd38dae0df3b635fe encountered an error during CreateProcess: failure in a Windows system call: System could not find the file. (0x2)

[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"bash","WorkingDirectory":"/","Environment":{"MONGO_DOWNLOAD_SHA256":"c4574977ea850798329bfdb6e912145f683afd3b28fe363abdf51ead33446a94","MONGO_DOWNLOAD_URL":"https://downloads.mongodb.org/win32/mongodb-win32-x86_64-2012plus-4.2.2-signed.msi","MONGO_VERSION":"4.2.2"},"EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[0,0]}

Things I have tried:

None of this worked, so I am missing something big or it's bug. I have read another posts but those where related to build apps and C# which is not what I want.

Notes: - OS: Windows 10 pro - I'm new to this and learning alone

Thanks for your time

EDIT:

Mongo Image

Upvotes: 1

Views: 7101

Answers (2)

Jonalca
Jonalca

Reputation: 576

I'm going to answer my own question after some days of reading documentation and learning new things about docker.

The answer is pretty simple and it's directed to those using a Docker Dektop on a Windows OS and want to use bash and thus having a similar problem to mine.

First of all, stop that image you tried to run unsuccesfully over and over and kill it.

Head over to that docker icon you have on your bottom left of your screen.

Click on the focker icon

Right click on it and choose 'switch to Linux containers'

wait a few seconds for the switch and then repeat the commands you used to run and exec your mongodb using bash.

The reason behind this error is that you are trying to use bash on a Windows container!

Upvotes: 1

prisar
prisar

Reputation: 3195

Remove all images related to mongo along with the dangling images. Then try to pull mongo again and after that run container.

Run this command to delete all images

docker system prune -a

Upvotes: 0

Related Questions