I want to use MongoDB in Docker for my local development and MongoDB Atlas for production. At this moment, MongoDB Atlas Free doesn’t provide a possibility to choose MongoDB 6.0.3 and locked to use 5.0.x.
As far as I understand, it is okay to use a MongoDB replica set with only one primary node for local development.
Is there any official guide that helps me to configure it with Docker?
You can follow the instructions in Convert a Standalone to a Replica Set. Basically after executing rs.initiate(), you don’t add more nodes to the replica set. By default, it should progress as a single node replica set as PRIMARY.
As with using Docker, this seems to work for me:
docker run --name some-mongo -p 27017:27017 mongo --replSet rsname
You should be able to connect to your host’s port 27017 using mongosh, then execute rs.initiate() there.
Note that this is a very basic example, so its storage is managed by Docker. If your needs are more specific, please see more detailed examples in Docker
Having said that, please note that the Docker Hub’s official MongoDB image is not maintained by MongoDB. Rather, it’s maintained by Docker.