So guys n gals, hope you can help me.
So i'm diving into docker containers right now and i try to port my application (flask+mongodb) into two seperate containers. MongoDB container is set up and works great, running a mongoexpress container with a link gives me the access to the database i wished. Now i ported my Flask application and the login page loads fine (so the docker port itself works) but even though i run the container with a link to my database container, i get a server error when i try to load content from the database.
The logs give me the following traceback:
File "/usr/local/lib/python3.7/site-packages/mongoengine/queryset/manager.py", line 37, in __get__
queryset = queryset_class(owner, owner._get_collection())
File "/usr/local/lib/python3.7/site-packages/mongoengine/document.py", line 190, in _get_collection
db = cls._get_db()
File "/usr/local/lib/python3.7/site-packages/mongoengine/document.py", line 179, in _get_db
return get_db(cls._meta.get('db_alias', DEFAULT_CONNECTION_NAME))
File "/usr/local/lib/python3.7/site-packages/mongoengine/connection.py", line 241, in get_db
db = conn[conn_settings['name']]
File "/usr/local/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1323, in __getitem__
return database.Database(self, name)
File "/usr/local/lib/python3.7/site-packages/pymongo/database.py", line 107, in __init__
"of %s" % (string_type.__name__,))
TypeError: name must be an instance of str
So my Flask-MongoEngine is set up like:
app = Flask(__name__)
app.config["MONGODB_DB"] = 'database-name'
db = MongoEngine(app)
Basically my database should be available on localhost at the standard port 27017. Is there anything i have to consider when connecting with Flask to the container or should the link not already expose the ports as expected?mongoexpress works and has access, so it has to be a problem with my setup.