I have been having quite a time connecting to a Dockerized instance of MongoDB. I was able to configure a MongoDB container per these instructions on my local development machine, but the same steps don't seem to work in production.
My exact steps to create, run and connect to the container:
Create and run the container
docker run --name prod-mongo -p 27017:27017 -d mongo --authAdded the initial user:
docker exec -it prod-mongo mongo admindb.createUser({user:'skipper', pwd:'skipperspassword', roles:[{role:'userAdminAnyDatabase',db:'admin'}] });Successfully connected to Docker container from another Mongo container:
docker run -it --rm --link prod-mongo:mongo mongo mongo -u skipper -p --authenticationDatabase admin prod-mongo/skippers-appsUnsuccessfully connected to Docker container from Docker host:
mongo skippers-apps --authenticationDatabase admin -u skipper -p
It's that last step that I'm concerned with. It works in my local development environment, but not production.
Development Environment
- Operating System: Mac OS El Capitan
- Kernel Version 15.6.0
- MongoDB Shell Version: 3.2.7
- Docker Version: 1.12.3
Production Environment
- Operating System: Ubuntu 16.04.1 LTS
- Kernel Version: 4.4.0
- MongoDB Shell Version: 2.6.10
- Docker Version: 1.12.3