Skip to content

Instantly share code, notes, and snippets.

@willianfalbo
Last active October 8, 2020 18:54
Show Gist options
  • Save willianfalbo/89d75f061ee8b7fe167fc76c61dc1a55 to your computer and use it in GitHub Desktop.
Save willianfalbo/89d75f061ee8b7fe167fc76c61dc1a55 to your computer and use it in GitHub Desktop.
How to get a mongo shell running into the docker container

How to get a mongo shell running into the docker container

We can run the interactive shell by running the following command:

docker container exec -it MyContainerName bash

Note: From this command, you will be able to get a bash shell running into the cointainer.

Then, we must get the mongo shell as admin. Otherwise, you will not be able to see the databases and collections.

Run mongo -u "USERNAME" -p "PASSWORD" HOSTIP --authenticationDatabase "admin"

That's it. Now, you are able to run any command such as show dbs.

References:

https://stackoverflow.com/questions/32944729/how-to-start-a-mongodb-shell-in-docker-container

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