我正在尝试在数据持久性的Bluemix上部署Mongodb docker容器,但是当系统尝试在主机(Bluemix)卷上的容器“/ data / db”上安装并且容器没有时,总是会收到错误不要开始。在过去的两天里,我研究并尝试了多个选项including one for Postgres on stackoverflow,但仍然遇到了同样的错误。任何帮助将不胜感激。
错误: $ docker logs f450993a-4cc; chown:更改'/ data / db'的所有权:权限被拒绝
docker-compose file:
mongodb:
container_name: mymongo
image: registry.ng.bluemix.net/helpfull/mongo:3.2.10
volumes:
- mongodb:/data/db:rw
ports:
- "27017"
答案 0 :(得分:0)
感谢Israel.Zinc对这个问题进行了很好的编辑,感谢Alex为你的建议。在使用基于previous post Redis solution krsyoung Connect to oracle from c#之后的脚本再玩一点之后,我能够以下列方式使其工作。我是Docker / Bluemix的新手,所以不确定这是否是正确的解决方案,但它工作正常,我希望它能为其他人节省时间。
<强>多克尔-撰写:强>
mongo:
container_name: hfmongo
image: registry.ng.bluemix.net/helpfull/hfmongo:3.4.2
volumes:
- mongodatabase:/data/db
ports:
- "27017"
<强> Dockerfile:强>
FROM mongo:3.4
COPY docker-entrypoint-bluemix.sh /
ENTRYPOINT ["/docker-entrypoint-bluemix.sh"]
EXPOSE 27017
CMD ["mongod"]
<强> docker-entrypoint-bluemix.sh 强>
#!/bin/bash
set -e
set -x
if [ "${1:0:1}" = '-' ]; then
set -- mongod "$@"
fi
if [[ "$1" == mongo* ]] && [ "$(id -u)" = '0' ]; then
STARTTIME=$(date +%s)
echo "START: hack for IBM Bluemix"
chmod 775 "/data/db"
adduser mongodb root
echo "END: hack for IBM Bluemix"
exec gosu mongodb "$BASH_SOURCE" "$@"
fi
exec "$@"