简体   繁体   English

在 Windows 上安装 mongoDB 作为 docker 镜像

[英]Installing mongoDB as a docker image on Windows

I am trying to install mongoDB as a docker image on a Windows 10 machine.我正在尝试将 mongoDB 作为 docker 映像安装在 Windows 10 机器上。 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:我尝试过的事情:

  • Execute as administrator.以管理员身份执行。
  • Remove it and repeat docker rm mongodb and back to the first step删除它并重复docker rm mongodb并返回到第一步
  • Another pull (It says its up to date)另一个拉(它说它是最新的)

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.我读过另一篇文章,但那些与构建应用程序和 C# 相关的文章不是我想要的。

Notes: - OS: Windows 10 pro - I'm new to this and learning alone注意: - 操作系统:Windows 10 专业版 - 我是新手,独自学习

Thanks for your time谢谢你的时间

EDIT:编辑:

蒙戈图像

I'm going to answer my own question after some days of reading documentation and learning new things about docker.在阅读了几天的文档并学习了有关 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.答案非常简单,它针对那些在 Windows 操作系统上使用 Docker Dektop 并希望使用 bash 并因此遇到与我类似的问题的人。

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.转到屏幕左下角的那个泊坞窗图标。

点击福克图标

Right click on it and choose 'switch to Linux containers'右键单击它并选择“切换到 Linux 容器”

wait a few seconds for the switch and then repeat the commands you used to run and exec your mongodb using bash.等待几秒钟的切换,然后重复您用于运行和使用 bash 执行 mongodb 的命令。

The reason behind this error is that you are trying to use bash on a Windows container!此错误背后的原因是您尝试在 Windows 容器上使用 bash!

Remove all images related to mongo along with the dangling images.删除与 mongo 相关的所有图像以及悬空图像。 Then try to pull mongo again and after that run container.然后尝试再次拉取 mongo,然后再运行容器。

Run this command to delete all images运行此命令删除所有图像

docker system prune -a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM