Configure connection to mongodb for querying only We have an external mongodb instance and we need to query data from it and bring it to Drupal 8 site.

On shell this is how we connect (mongodb is running in a different container than drupal)
mongo --host docker_mongo --ssl --sslCAFile=/etc/ssl/mongodb-cert.crt 

Adding the following at settings.php does not work and status report shows "No database aliases found in settings. Did you actually configure your settings ?"

$configureMongoDb = function (array $settings): array {
  $settings['mongodb'] = [
    'clients' =&gt; [
      // Client alias =&gt; connection constructor parameters.
      'mymongo' =&gt; [
        'uri' =&gt; 'mongodb://docker_mongo:27017',
        'uriOptions' =&gt; ['ssl=true&amp;sslCAFile=/etc/ssl/mongodb-cert.crt'],
        'driverOptions' =&gt; [],
      ],
    ],
    'databases' =&gt; [
      // Database alias =&gt; [ client_alias, database_name ].
      'tutorial2' =&gt; ['mymongo', 'tutorial2'],
    ],
  ];

  return $settings;
};


Could anyone suggest how to connect to a mongodb instance?

Cross-posting this question at drupal-mongodb issue as well
You don't need to set a function in settings.php to define the connection. The documentation lists this as an example:

https://fgm.github.io/mongodb/install/#settings-configuration

// In sites/default/settings.local.php.
$settings['mongodb'] = [
  'clients' =&gt; [
    // Client alias =&gt; connection constructor parameters.
    'default' =&gt; [
      'uri' =&gt; 'mongodb://localhost:27017',
      'uriOptions' =&gt; [],
      'driverOptions' =&gt; [],
    ],
  ],
  'databases' =&gt; [
    // Database alias =&gt; [ client_alias, database_name ]
    'default' =&gt; ['default', 'drupal'],
    'keyvalue' =&gt; ['default', 'keyvalue'],
    'logger' =&gt; ['default', 'logger'],
  ],
];