Syntax issue with adding creating a mongodb and user with roles

I’ve started building my first docker container for a mongodb with auth.

I have a python script that fetches credentials from our password safe and makes them available for a bash script which then sets up the admin db and users.

  • Can and should Node/NPM be used in a separate container for a dockerized PHP application
  • Docker java api maven Build error: busybox is an unrecognized image. Please pull the image first
  • Is it possible to ignore a subfolder (e.g. node_module) in the mounted Volume in a docker container?
  • Docker Compose on Windows 7: Could not locate Gemfile or .bundle/ directory
  • How to export Docker-machine configuration to be used on other machines
  • ERROR: Registering runner. forbidden (check registration token)
  • I use a RUN command for the python script and that is fine.

    The bash script runs perfectly when I log into the container and run it.

    However, it should run as part of a CMD surely?

    Dockerfile extract:

    ADD /
    ADD /
    RUN chmod +x /
    RUN chmod +x /
    RUN python / <user> <password>
    CMD ["/bin/bash","/"]

    Bash script

    mongod --auth
    source mongodb_credentials.txt
    # Wait for MongoDB to boot
    while [[ RET -ne 0 ]]; do
        echo "=> Waiting for confirmation of MongoDB service startup..."
        sleep 5
        mongo admin --eval "help" >/dev/null 2>&1
    echo "=> Creating admin user"
    mongo admin --eval "db.createUser({user: '$MONGO_ADMIN_USER', pwd: '$MONGO_ADMIN_PASSWORD', roles:[{role:'userAdminAnyDatabase',db:'admin'}]});"
    sleep 3
    echo "=> Creating IawApi user"
    mongo admin -u $MONGO_ADMIN_USER -p $MONGO_ADMIN_PASSWORD --eval "db.createUser({user: '$MONGO_IAWAPI_USER', pwd: '$MONGO_IAWAPI_PASSWORD', roles:[{role:'dbOwner',db:'IawApi'}]});"
    echo "=> Creating vpnDebugger user"
    mongo admin -u $MONGO_ADMIN_USER -p $MONGO_ADMIN_PASSWORD --eval "db.createUser({user: '$MONGO_VPNDEBUGGER_USER', pwd: '$MONGO_VPNDEBUGGER_PASSWORD', roles:[{role:'dbOwner',db:'vpnDebugger'}]});"
    echo "Done!"
    # delete anything that can be used to gain access to credentials
    rm -f mongodb_credentials.txt
    rm -f

  • How to edit files in a Confluence docker container? There is no vim and apt-get in it
  • Creating topics, but getting Kafka FailedPayloadsError with Python on Kubernetes
  • Giving full access to eth1 to docker container
  • Nodemon Doesn't Restart in Windows Docker Environment
  • Docker port binding using gitlab-ci with gitlab-runner
  • Why is the Node.js AWS-SDK returning the wrong SQS queue URL when creating a local queue
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.