MongoDB docker image with a shell script wrapper that has some conveniences. This is based on Tutum's docker container.
Run the following command to start MongoDB:
docker run -d -p 27017:27017 -p 28017:28017 wayblazer/mongodb
You can run the docker logs command to see initialization information about the container.
docker logs <CONTAINER_ID>
You will see output with the WayBlazer insignia at the top. You should see output from the shell script, Supervisord, and initial user information like:
========================================================================
You can now connect to this MongoDB server using:
mongo admin -u admin -p 5elsT6KtjrqV --host <host> --port <port>
Please remember to change the above password as soon as possible!
========================================================================
In this case, 5elsT6KtjrqV is the password set.
You can then connect to MongoDB:
mongo admin -u admin -p 5elsT6KtjrqV
Done!
If you want to use a preset password instead of a randomly generated one, you can
set the environment variable MONGODB_PASS to your specific password when running the container:
docker run -d -p 27017:27017 -p 28017:28017 -e MONGODB_PASS="mypass" wayblazer/mongodb
You can now test your new admin password:
mongo admin -u admin -p mypass
curl --user admin:mypass --digest http://localhost:28017/
If you want to run MongoDB without password you can set the environment variable AUTH to specific if you want password or not when running the container:
docker run -d -p 27017:27017 -p 28017:28017 -e AUTH=no wayblazer/mongodb
By default is "yes".
Ideally, we want to create other users with different access credentials to different databases outside the 'baked' container, so we're not storing hardcoded usernames and passwords. The best way to do this is to use the create_mongodb_users script in the container:
docker run --rm wayblazer/mongodb ./create_mongodb_users.sh <mongo_hostname> <database> <admin_user> <admin_password> <new_user_to_create> <password_for_new_user>
Here we leverage the same container (no overhead) to connect to the mongodb server container and run the CLI against it using the admin user/pass created above. It will create the users and exit, removing the temporary containers.
In MongoDB 3.0 there is a new environment variable STORAGE_ENGINE to specific the mongod storage driver:
docker run -d -p 27017:27017 -p 28017:28017 -e AUTH=no -e STORAGE_ENGINE=mmapv1 wayblazer/mongodb:3.0
By default is "wiredTiger".
In MongoDB 3.0 the variable OPLOG_SIZE can be used to specify the mongod oplog size in megabytes:
docker run -d -p 27017:27017 -p 28017:28017 -e AUTH=no -e OPLOG_SIZE=50 wayblazer/mongodb:3.0
By default MongoDB allocates 5% of the available free disk space, but will always allocate at least 1 gigabyte and never more than 50 gigabytes.
Content type
Image
Digest
sha256:2e0f7edc4…
Size
107.5 MB
Last updated
over 10 years ago
docker pull wayblazer/mongodb