Last active
July 16, 2023 18:18
-
Star
(109)
You must be signed in to star a gist -
Fork
(53)
You must be signed in to fork a gist
-
-
Save davideicardi/f2094c4c3f3e00fbd490 to your computer and use it in GitHub Desktop.
Revisions
-
davideicardi renamed this gist
Mar 24, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
davideicardi revised this gist
Dec 19, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,3 +27,9 @@ exit # now you can connect with the admin user (from any mongo client >=3 ) # remember to use --authenticationDatabase "admin" mongo -u "foouser" -p "foopwd" YOURHOSTIP --authenticationDatabase "admin" # If hosted on Azure set the docker host keep alive timeout to less than 240 seconds # that is the default keep alive time on Azure network infrastructure (Public Ip only) # See also # https://docs.mongodb.org/ecosystem/platforms/windows-azure/ # http://stackoverflow.com/questions/34373003/connection-timeout-to-mongodb-on-azure-vm -
davideicardi revised this gist
Dec 12, 2015 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,8 @@ # Create a container from the mongo image, # run is as a daemon (-d), expose the port 27017 (-p), # set it to auto start (--restart) # and with mongo authentication (--auth) # Image used is https://hub.docker.com/_/mongo/ docker pull mongo docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth -
davideicardi revised this gist
Dec 12, 2015 . 1 changed file with 18 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,25 @@ # Create a container from the mongo image, run is as a daemon (-d), expose the port 27017 (-p) docker pull mongo docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth # Using the mongo "localhost exception" (https://docs.mongodb.org/v3.0/core/security-users/#localhost-exception) # add a root user # bash into the container sudo docker exec -i -t YOURCONTAINERNAME bash # connect to local mongo mongo # create the first admin user use admin db.createUser({user:"foouser",pwd:"foopwd",roles:[{role:"root",db:"admin"}]}) # exit the mongo shell exit # exit the container exit # now you can connect with the admin user (from any mongo client >=3 ) # remember to use --authenticationDatabase "admin" mongo -u "foouser" -p "foopwd" YOURHOSTIP --authenticationDatabase "admin" -
davideicardi revised this gist
Dec 12, 2015 . 2 changed files with 23 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ # Create a container from the mongo image, run is as a daemon (-d), expose the port 27017 (-p) docker pull mongo docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo # Now connect to mongo using mongodb shell and create an administrator user: mongo YOURIP use admin db.createUser( { user: "myUserAdmin", pwd: "abc123", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ) exit Attach to the container with bash: sudo docker exec -i -t YOURCONTAINERNAME bash This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +0,0 @@ -
davideicardi revised this gist
Dec 12, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,3 +13,6 @@ Now connect to mongo using mongodb shell and create an administrator user: } ) Exit the mongoshell, and attach to the container with bash: sudo docker exec -i -t YOURCONTAINERNAME bash -
davideicardi revised this gist
Dec 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ Create a container from the mongo image, run is as a daemon (-d), expose the port 27017 (-p) and use the host network (--net host) docker run --name=YOURCONTAINERNAME -d -p 27017 --net host mongo Now connect to mongo using mongodb shell and create an administrator user: use admin db.createUser( { -
davideicardi created this gist
Dec 12, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ Create a container from the mongo image, run is as a daemon (-d), expose the port 27017 (-p) and use the host network (--net host) docker run --name=YOURCONTAINERNAME -d -p 27017 --net host mongo Now connect to mongo using mongodb shell and create an administrator user: use admin db.createUser( { user: "myUserAdmin", pwd: "abc123", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } )