User not found on MongoDB Docker image with authentication

So I’m trying to setup a MongoDB using the official mongo Docker image, version 4.2. What I want to achieve is to use the server with authentication enabled, and I want to have a custom database with a custom user and password. So, I’m setting the following environment variables: MONGO_INITDB_DATABASE: mydb MONGO_INITDB_ROOT_USERNAME: jane MONGO_INITDB_ROOT_PASSWORD: secret…

MongoDB – mongodump collections with a limit

Is there a way to mongodump a database with 10+ collections and grab the last 100 objects in each collection? Here’s what I’ve been training, but it’s not working: mongodump –gzip –uri=”mongodb://$IP:$PORT/$DB” \ –collection=$COLLECTION \ –archive=$COLLECTION.gz \ –query=”{ \”\$limit\”: 100 }” Here’s the output: Failed: (command failure) Can’t canonicalize query: BadValue unknown top level operator:…

How to add a new node to a mongodb replica set in docker swarm (docker compose 3.4)

I’m trying to intialize a mongo replica set mode and add two nodes(swarm services) to it, I’m using docker-compose 3.4 I’m using a script shell that I execute on an ansible playbook (version 2.7.10) The following pieces of code are respectively the docker-compose, the ansible playbook and the shell script: version: ‘3.4’ services: mongo: image:…