IBM Bluemix: Not able to mount the MongoDB container “/data/db” on the Bluemix host volume

I am trying to deploy a Mongodb docker container on Bluemix w/ data persistence but always getting the error when the system is trying to mount on the container “/data/db” on the host (Bluemix) volume and the container doesn’t start. For the last 2 days, I have researched and tried multiple options, including one for Postgres on stackoverflow, but still getting the same error. Any help would be greatly appreciated.

Error: $ docker logs f450993a-4cc ;chown: changing ownership of ‘/data/db’: Permission denied

  • Linux Container vs JVM
  • Docker: Running multiple applications VS running multiple containers
  • Is there a way to rename network interfaces in Docker swarm?
  • Why does Docker build take long time in “Sending context to daemon” step?
  • Wait for job/pod completion in Kubernetes or Google Container Engine
  • Cannot change ownership of host directory mounted with docker-machine on MAC
  • docker-compose file:


      container_name: mymongo
        - mongodb:/data/db:rw
        - "27017"

  • How to share .sock file between nginx docker and uwsgi docker?
  • Creating a CI pipeline for .net containerized applications
  • How can a script distinguish Docker Toolbox and Docker for Windows?
  • Can I use restarting docker instead restarting app in container?
  • Laradock: how to enable/install php7 ldap support extension?
  • How can I set up a Docker network with restricted communication?
  • One Solution collect form web for “IBM Bluemix: Not able to mount the MongoDB container “/data/db” on the Bluemix host volume”

    Thank you Israel.Zinc for the nice editing of the question and Alex for your suggestion. After playing little bit more with the script based on the previous post about Redis solution by krsyoung, I was able to make it work in the following way. I am new to Docker/Bluemix so not sure if this is the right solution but it is working fine and I hope it will save time for some other people.


      container_name: hfmongo
        - mongodatabase:/data/db
        - "27017"


    FROM mongo:3.4
    COPY /
    ENTRYPOINT ["/"]
    EXPOSE 27017
    CMD ["mongod"]

    set -e
    set -x
    if [ "${1:0:1}" = '-' ]; then
      set -- mongod "$@"
    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" "$@"
    exec "$@"
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.