title: PyMongo Auth Failure: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'
body: <p>Curious thing, I am running SLS Python Lambdas in a Docker container with the MongoDB instance in a separate container. I am able to authenticate from an exposed port on my host to connect to the instance.</p>
  <p>However, from inside SLS container for whatever reason it does not want to connect :S</p>
  <pre class="lang-py prettyprint-override"><code># mongodb://root:password@mongodb/test_db?retryWrites=true&amp;w=majority
  db_uri = &quot;mongodb://&quot; + usr + &quot;:&quot; + pwd + &quot;@&quot; + url + &quot;/test_db?retryWrites=true&amp;w=majority&quot;
  client = pymongo.MongoClient(db_uri)
  
  db = client[mongo_db_name]
  collection = db[mongo_collection_name]
  </code></pre>
  <pre><code>version: &quot;3.8&quot;
  services:
    mongodb:
      image : mongo
      environment:
        - MONGO_INITDB_ROOT_USERNAME=root
        - MONGO_INITDB_ROOT_PASSWORD=password
        - MONGO_INITDB_DATABASE=test_db
        - PUID=1000
        - PGID=1000
      ports: 
        - &quot;27000:27017&quot;
      restart: unless-stopped
      volumes:
        - ./mongodb/init.js:/docker-entrypoint.initdb.d/init.js
  
    python:
      build: python
      depends_on:
        - mongodb
      ports: 
        - &quot;3000:3000&quot;
      restart: unless-stopped
      volumes:
        - ./python:/usr/src/app
  </code></pre>