Last active
November 20, 2022 12:18
-
-
Save alaztetik/8c44177dd6ab50c8440a3cc9be830fb4 to your computer and use it in GitHub Desktop.
Revisions
-
alaztetik revised this gist
Nov 20, 2022 . No changes.There are no files selected for viewing
-
alaztetik created this gist
Nov 20, 2022 .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,24 @@ # commands may need sudo # pull MongoDB image: docker pull mongo # start container: docker run -d \ --name CONTAINER_NAME \ -p LOCALHOST_PORT_NUMBER \ -e MONGO_INITDB_ROOT_USERNAME=username \ -e MONGO_INITDB_ROOT_PASSWORD=password \ mongo # check if the contaier is running: docker container ls # start ad connect to a bash shell within the container: docker exec -it CONTAINER_NAME bash # access MongoDB instance via CLI: mongosh --username username --password password # use URI to connect to db from outside the container: mongodb://username:[email protected]:PORT/