Mongo daemon doesn't run by service mongod start

戏子无情 提交于 2019-12-03 14:53:49

Docker containers typically does not have a full init system and interaction with upstart will not work inside a docker container. (In theory it is possible, but it defeats the purposes of having light weight stack)

What this implies is that you start a docker container, it would run a single command "/usr/bin/mongod"

Example of running mongodb inside a docker container: https://docs.docker.com/samples/library/mongo/

Also since you are running installation commands using an interactive docker container, your shell interpreter is the single command as far as docker is considered. Once in interactive session, you can run mongod in background (As you did) and start mongo client session.

Another way would be to run these instructions as part of Dockerfile. You can refer to mongodb example.

You might also want to consider some of the official mongo db images already published in docker hub:

https://registry.hub.docker.com/_/mongo/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!