Sign inSign up

lastbackend/mongodb

By lastbackend

•Updated almost 11 years ago

Image
1

2.6K

lastbackend/mongodb repository overview

⁠lb-docker-mongodb

Base docker image to run a MongoDB database server

⁠Usage

To create the image lastbackend/mongodb, execute the following command on the lb-docker-mongodb folder:

docker build -t lastbackend/mongodb .

⁠Running the MongoDB server

Run the following command to start MongoDB:

docker run -d -p 27017:27017 -p 28017:28017 lastbackend/mongodb

The first time that you run your container, a new random password will be set. To get the password, check the logs of the container by running:

docker logs <CONTAINER_ID>

You will see an output like the following:

--------------------------------------- MongoDB ----------------------------------------
  +-++-+ mongo admin -u admin -p DFZmFTlDe34rsjiDstPHKezJ --host «host» --port «port»
  | LB |
  +-++-+ Please remember to change the above password!
----------------------------------------------------------------------------------------

In this case, DFZmFTlDe34rsjiDstPHKezJ is the password set. You can then connect to MongoDB:

mongo admin -u admin -p 5elsT6KtjrqV

Done!

⁠Setting a specific password

If you want to use a preset password instead of a random generated one, you can set the environment variable PASS to your specific password when running the container:

docker run -d -p 27017:27017 -p 28017:28017 -e USER=admin -e PASS="mypass" lastbackend/mongodb

--------------------------------------- MongoDB ----------------------------------------
  +-++-+ mongo admin -u admin -p «password» --host «host» --port «port»
  | LB |
  +-++-+ Please remember to change the above password!
----------------------------------------------------------------------------------------

You can now test your new admin password:

mongo admin -u admin -p mypass
curl --user admin:«password» --digest http://localhost:28017/

⁠Run MongoDB without password

If you want run MongoDB without password you can set tge 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 lastbackend/mongodb

By default is "yes".

by http://www.lastbackend.com⁠

Tag summary

Content type

Image

Digest

sha256:68c4212a9…

Size

132.5 MB

Last updated

almost 11 years ago

docker pull lastbackend/mongodb