我有dockerfile,它可以在容器中正确安装Mongodb和Ops管理器。之后,我使用entrypoint.sh进行设置,在脚本的末尾我放了:
echo "starting mongodb"
service mongod start
echo "starting opsmgr"
service mongodb-mms start
当我运行容器时,从日志消息来看,启动操作管理器行的那行从未被执行过。
我该怎么做呢:如果mongodb是up的,那么执行service mongodb-mms start
不确定它是否在一个容器中运行多个服务,因为运维管理器需要等待mongodb正确启动。
发布于 2019-02-18 19:07:32
我为一个非常旧的Ops Manager版本找到了这个Dockerfile
,但是它等待mongodb端口打开的方式仍然有效:https://github.com/deviantony/docker-opsmanager/blob/master/ops-manager/startup.sh
基本上,作者使用nc
等待,直到标准mongod
端口接受连接:
echo "Waiting for MongoDB"
while true; do
nc -q 1 database 27017 >/dev/null && break
done
现在,在调用Ops Manager时,请确保它保持在前台,因为Docker需要一个进程才能运行。
例如,您可以从service start mongodb-mms
开始,然后立即运行tail,例如:
echo "starting mongodb"
service mongod start
# snippet to wait for mongod to be in running state
echo "starting opsmgr"
service mongodb-mms start
# Keep this startup script busy, if it ends, the Docker container dies.
tail -f /opt/mongodb/mms/logs/mms0.log
https://stackoverflow.com/questions/51434440
复制相似问题