A Docker image for MongoDB with authentication enabled by default. It also has remote access enabled to facilitate the external connections.
This image inherits directly from the official MongoDB image in the Docker Store.
Run the container using pre-built image vegidio/mongodb:
$ docker run -d \ -e MONGODB_ROOT_PASSWORD='password' \ -p 27017:27017 \ --name mongodb vegidio/mongodb
You must replace the environment variable
MONGODB_ROOT_PASSWORD for an unique and secure password. See more in the Authentication section.
Build the image
In the project root folder, type:
$ docker build -t my-mongodb-image .
Then run the container using the same command available in the Pre-built image section, but replacing
vegidio/mongodb by the name of the image you just built.
This MongoDB image has authentication enabled by default. It means that you must use a password to access the database server.
In order to set a password you must create the environment variable
MONGODB_ROOT_PASSWORD when you run the Docker container (either with the parameter
-e MONGODB_ROOT_PASSWORD or through the docker-compose.yml file). If you don't create this environment variable then this image will set the default password
"root" for you, but I strongly advice against using the default password! Your data can be in risk if you do this.
With the password set, a new user named root will be created in the database.
Port & Remote Connections
This container exposes MongoDB's default port 27017 for private connections. If you want to allow this container to be accessed remotely then you must map the private port to a public one, using the Docker parameter
vegidio/mongodb is released under the Apache License. See LICENSE for details.
Vinicius Egidio (vinicius.io)