Skip to content

Instantly share code, notes, and snippets.

@byk0t
Created July 1, 2020 20:08
Show Gist options
  • Save byk0t/5326de4fe66384e999a9079198105996 to your computer and use it in GitHub Desktop.
Save byk0t/5326de4fe66384e999a9079198105996 to your computer and use it in GitHub Desktop.
How to connect to mongodb in docker container from localhost
# sample command from dockerhub
docker run --name some-mongo -d mongo:tag
# but to make mongo available from localhost you should change this command a bit
docker run --name some-mongo -p 27017:27017 -d mongo:tag
# so now you can connect to the mongo using the next command
mongo -host localhost -port 27017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment