MongoDB & Docker: connections from Dockerized Mongo client to external server refused

I’ve got a mongod instance running on server A. Server B has a Dockerized container for our web app (apache, django, mongoengine). Server B’s mongo client needs to connect to A’s mongod instance. I can connect through the shell and pymongo without trouble from B to A but my Dockerized django app’s connections are refused.

ConnectionError: Cannot connect to database test :
[Wed Mar 11 17:30:49.452307 2015] [:error] [pid 13:tid 140069001664256] [client <client ip>] [Errno 111] Connection refused

This is how I’m connecting using mongoengine:

  • couldn't run docker when mount volume
  • Docker-machine ip in Dockerfile
  • symmetricds on Docker and Kubernetes for Google Container Engine Deployment
  • Docker: `Repository name must match …` error
  • Docker How to connect to MongoDB from Web Service inside Container
  • Error while is docker pull image
  • register_connection(alias="test", name="test", host="mongodb://user:pwd@<server ip>:27017/test?ssl=true")
    connect(db="test", alias="test")
    

    And running the Docker container

    docker run -d -p 443:443 -p 27017:27017 me/webapp
    

    I’ve also set ip_forward to 1 as per the docs.

    What am I missing?

  • Compute Engine / gcloud in VM - is this the right way?
  • Is it possible to integrate SonarQube, Jenkins and GitLab (all in dockers)?
  • persist and share data from docker mongo container (with docker)
  • What run flags are included in my Docker Container
  • OSX terminal vs Docker CLI
  • Connect to Windows 10 Docker daemon from ubuntu bash
  • One Solution collect form web for “MongoDB & Docker: connections from Dockerized Mongo client to external server refused”

    As it turns out it had nothing to do with Docker or mongoengine (directly). Pymongo 2.7.2 does not support SCRAM-SHA-1 authentication. The solution is to install the 2.8 release candidate.

    pip install git+git://github.com/mongodb/mongo-python-driver.git@2.8rc0
    

    See the Jira ticket which was helpful and the pymongo blog post which ultimately provided me with a fix.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.