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:

  • Mounted lvm volume not passed to container
  • Vagrant and Docker not playing nice
  • why does docker-compose up remove other running conainters?
  • Why does docker crash on high memory usage?
  • docker login - Keep Session Alive on CI Server - Stay Logged In
  • Mattermost docker preview
  • 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?

  • go-dockerclient `UploadToContainer` tar examples
  • libcontainer, runc and nsenter bootstrap
  • “Error: mysqli_connect() No Such File or Directory”. PHP 7 FPM, MariaDB, Nginx, Docker
  • Copy all SBT dependencies to local folder
  • Docker base images, what do they compose of?
  • Write permissions for IBM Containers Volume as non-root user
  • 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.