Skip to content

Instantly share code, notes, and snippets.

@davideicardi
Last active July 16, 2023 18:18
Show Gist options
  • Save davideicardi/f2094c4c3f3e00fbd490 to your computer and use it in GitHub Desktop.
Save davideicardi/f2094c4c3f3e00fbd490 to your computer and use it in GitHub Desktop.
Running mongodb inside a docker container (with mongodb authentication)

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" } ] } )

@DavidBrionesFF
Copy link

no puedo conectarme de manera remota

@Tariqs
Copy link

Tariqs commented Jan 22, 2021

Very helpful ❤️

@baniahmad
Copy link

i love you bro. helpful 😘😘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment