MongoError: database name must be string

My node backend is connecting to Cosmos Db using the Mongo API.
Connecting via mongoose via the below steps yields the error

MongoError: database name must be a string

when running in docker. It runs just fine when using nodemon, i.e. outside of docker container.

( < any > Mongoose).Promise = global.Promise;
const options: ConnectionOptions = {useNewUrlParser: true, useFindAndModify: false};
const mongoURI: string = process.env.COSMOS_DB_CONN_STR;
connect(mongoURI, options)
.then(() => console.log(`Mongo DB: connected`))
.catch(err => console.log(`Could not connect. Error: ${err}`));

process.env.COSMOS_DB_CONN_STR is of the format


Any thoughts why this is happening? The test environment of this service uses a separate cosmos db which works fine, inside and outsode of docker.

Source: StackOverflow